Write test on page response

2017-05-06 Thread Yurij Shinkarev
Hello all.
I have page, this page return StreamResponse (json). So, I have in code:

StreamResponse onActivate() {  }

I want write a test for this page.
I can send PUT/GET/POST/DELETE request with different parameters.
Server return me some result.
I want test this results.
How I can did it?


Re: Selenium test cases fail building 5.4

2016-02-27 Thread Barry Books
No problem I've had this problem many times before. The thing that threw me
at first was the error I got running from Eclipse was "address already in
use" so I spent a bunch of time trying to figure out what that could
possibly be.

On Friday, February 26, 2016, Bob Harner <bobhar...@gmail.com> wrote:

> Yep, sorry we didn't get the docs updated before you ran into that. As you
> saw, an older Firefox version is needed. (Or, current Firefox versions work
> with upgraded versions of Selenium (v2.52.0) long as a build.gradle is
> switched to use Java 1.7 or newer.)
> Firefox 42 worked
>
> On Friday, February 26, 2016, Barry Books <trs...@gmail.com <javascript:;>>
> wrote:
>
> > I downloaded Firefox version 40 and it at least tries to run the test
> > cases but crashes. Is there a preferred version?
> >
> > On Friday, February 26, 2016, Barry Books <trs...@gmail.com
> <javascript:;>
> > <javascript:_e(%7B%7D,'cvml','trs...@gmail.com <javascript:;>');>>
> wrote:
> >
> >> Now that 5.4 is out I'd like to submit a couple of small patches so I
> >> downloaded 5.4 and followed the instructions here
> >>
> >> https://tapestry.apache.org/building-tapestry-from-source.html
> >>
> >> everything went smoothly but the following tests fail
> >>
> >> ActivationContextIntegrationTests. testStartup
> >>
> >> ActivationContextIntegrationTests2. testStartup
> >>
> >> DoctypeTests. testStartup
> >>
> >> PageCatalogTests. testStartup
> >>
> >> ProductionModeTests. testStartup
> >>
> >> AppFolderTests. testStartup
> >>
> >> LinkTransformerIntegrationTest. testStartup
> >>
> >> ReloadTests. testStartup
> >>
> >> GridSymbolDemoTests. testStartup
> >>
> >> When I run gradle build from the command line I get this message in
> >> Firefox (version 44.0.2) running on OS X 10.11.3
> >>
> >> Firefox can't find the file at
> >>
>
> chrome://src/content/RemoteRunner.html?sessionId=2b72c3d62fe64efc89a7a00e35e19f1c=true=
> >>
>
> http://localhost:9090/=false=http://localhost:/selenium-server/driver/
> >> .
> >>
> >> which seems to match this issue which basically says this is deprecated
> >> and no longer works
> >>
> >> https://github.com/SeleniumHQ/selenium/issues/1444
> >>
> >> Is this the case or is there some other trick that's not in the build
> >> instructions?
> >>
> >>
> >>
> >>
>


Re: Selenium test cases fail building 5.4

2016-02-26 Thread Bob Harner
Yep, sorry we didn't get the docs updated before you ran into that. As you
saw, an older Firefox version is needed. (Or, current Firefox versions work
with upgraded versions of Selenium (v2.52.0) long as a build.gradle is
switched to use Java 1.7 or newer.)
Firefox 42 worked

On Friday, February 26, 2016, Barry Books <trs...@gmail.com> wrote:

> I downloaded Firefox version 40 and it at least tries to run the test
> cases but crashes. Is there a preferred version?
>
> On Friday, February 26, 2016, Barry Books <trs...@gmail.com
> <javascript:_e(%7B%7D,'cvml','trs...@gmail.com');>> wrote:
>
>> Now that 5.4 is out I'd like to submit a couple of small patches so I
>> downloaded 5.4 and followed the instructions here
>>
>> https://tapestry.apache.org/building-tapestry-from-source.html
>>
>> everything went smoothly but the following tests fail
>>
>> ActivationContextIntegrationTests. testStartup
>>
>> ActivationContextIntegrationTests2. testStartup
>>
>> DoctypeTests. testStartup
>>
>> PageCatalogTests. testStartup
>>
>> ProductionModeTests. testStartup
>>
>> AppFolderTests. testStartup
>>
>> LinkTransformerIntegrationTest. testStartup
>>
>> ReloadTests. testStartup
>>
>> GridSymbolDemoTests. testStartup
>>
>> When I run gradle build from the command line I get this message in
>> Firefox (version 44.0.2) running on OS X 10.11.3
>>
>> Firefox can't find the file at
>>
chrome://src/content/RemoteRunner.html?sessionId=2b72c3d62fe64efc89a7a00e35e19f1c=true=
>>
http://localhost:9090/=false=http://localhost:/selenium-server/driver/
>> .
>>
>> which seems to match this issue which basically says this is deprecated
>> and no longer works
>>
>> https://github.com/SeleniumHQ/selenium/issues/1444
>>
>> Is this the case or is there some other trick that's not in the build
>> instructions?
>>
>>
>>
>>


Re: Selenium test cases fail building 5.4

2016-02-26 Thread Barry Books
Firefox 42 worked

On Friday, February 26, 2016, Barry Books <trs...@gmail.com> wrote:

> I downloaded Firefox version 40 and it at least tries to run the test
> cases but crashes. Is there a preferred version?
>
> On Friday, February 26, 2016, Barry Books <trs...@gmail.com
> <javascript:_e(%7B%7D,'cvml','trs...@gmail.com');>> wrote:
>
>> Now that 5.4 is out I'd like to submit a couple of small patches so I
>> downloaded 5.4 and followed the instructions here
>>
>> https://tapestry.apache.org/building-tapestry-from-source.html
>>
>> everything went smoothly but the following tests fail
>>
>> ActivationContextIntegrationTests. testStartup
>>
>> ActivationContextIntegrationTests2. testStartup
>>
>> DoctypeTests. testStartup
>>
>> PageCatalogTests. testStartup
>>
>> ProductionModeTests. testStartup
>>
>> AppFolderTests. testStartup
>>
>> LinkTransformerIntegrationTest. testStartup
>>
>> ReloadTests. testStartup
>>
>> GridSymbolDemoTests. testStartup
>>
>> When I run gradle build from the command line I get this message in
>> Firefox (version 44.0.2) running on OS X 10.11.3
>>
>> Firefox can't find the file at
>> chrome://src/content/RemoteRunner.html?sessionId=2b72c3d62fe64efc89a7a00e35e19f1c=true=
>> http://localhost:9090/=false=http://localhost:/selenium-server/driver/
>> .
>>
>> which seems to match this issue which basically says this is deprecated
>> and no longer works
>>
>> https://github.com/SeleniumHQ/selenium/issues/1444
>>
>> Is this the case or is there some other trick that's not in the build
>> instructions?
>>
>>
>>
>>


Re: Selenium test cases fail building 5.4

2016-02-26 Thread Barry Books
I downloaded Firefox version 40 and it at least tries to run the test cases
but crashes. Is there a preferred version?

On Friday, February 26, 2016, Barry Books <trs...@gmail.com> wrote:

> Now that 5.4 is out I'd like to submit a couple of small patches so I
> downloaded 5.4 and followed the instructions here
>
> https://tapestry.apache.org/building-tapestry-from-source.html
>
> everything went smoothly but the following tests fail
>
> ActivationContextIntegrationTests. testStartup
>
> ActivationContextIntegrationTests2. testStartup
>
> DoctypeTests. testStartup
>
> PageCatalogTests. testStartup
>
> ProductionModeTests. testStartup
>
> AppFolderTests. testStartup
>
> LinkTransformerIntegrationTest. testStartup
>
> ReloadTests. testStartup
>
> GridSymbolDemoTests. testStartup
>
> When I run gradle build from the command line I get this message in
> Firefox (version 44.0.2) running on OS X 10.11.3
>
> Firefox can't find the file at
> chrome://src/content/RemoteRunner.html?sessionId=2b72c3d62fe64efc89a7a00e35e19f1c=true=
> http://localhost:9090/=false=http://localhost:/selenium-server/driver/
> .
>
> which seems to match this issue which basically says this is deprecated
> and no longer works
>
> https://github.com/SeleniumHQ/selenium/issues/1444
>
> Is this the case or is there some other trick that's not in the build
> instructions?
>
>
>
>


Selenium test cases fail building 5.4

2016-02-26 Thread Barry Books
Now that 5.4 is out I'd like to submit a couple of small patches so I
downloaded 5.4 and followed the instructions here

https://tapestry.apache.org/building-tapestry-from-source.html

everything went smoothly but the following tests fail

ActivationContextIntegrationTests. testStartup

ActivationContextIntegrationTests2. testStartup

DoctypeTests. testStartup

PageCatalogTests. testStartup

ProductionModeTests. testStartup

AppFolderTests. testStartup

LinkTransformerIntegrationTest. testStartup

ReloadTests. testStartup

GridSymbolDemoTests. testStartup

When I run gradle build from the command line I get this message in Firefox
(version 44.0.2) running on OS X 10.11.3

Firefox can't find the file at
chrome://src/content/RemoteRunner.html?sessionId=2b72c3d62fe64efc89a7a00e35e19f1c=true=
http://localhost:9090/=false=http://localhost:/selenium-server/driver/
.

which seems to match this issue which basically says this is deprecated and
no longer works

https://github.com/SeleniumHQ/selenium/issues/1444

Is this the case or is there some other trick that's not in the build
instructions?


Re: How do I unit test Javascript in Tapestry applications?

2015-08-19 Thread Lance Java
A word of warning... Selenium tests can be very problematic and I'm sitting
on the fence as to whether they are actually worth the maintenance cost.

That being said, the tapestry build itself has comprehensive Selenium
tests. Have a look through the source code for examples.
On 17 Aug 2015 12:55, Poggenpohl, Daniel 
daniel.poggenp...@isst.fraunhofer.de wrote:

 Hello,

 We're trying to test our Tapestry application. We know that we can test
 our pages with
 https://tapestry.apache.org/unit-testing-pages-or-components.html

 But how do we test the JavaScript we implemented? It would seem that we
 would need a Tapestry generated html page and then call the scripts somehow.

 How do you implement JavaScript testing?

 Regards,
 Daniel P.



How do I unit test Javascript in Tapestry applications?

2015-08-17 Thread Poggenpohl, Daniel
Hello,

We're trying to test our Tapestry application. We know that we can test our 
pages with
https://tapestry.apache.org/unit-testing-pages-or-components.html

But how do we test the JavaScript we implemented? It would seem that we would 
need a Tapestry generated html page and then call the scripts somehow.

How do you implement JavaScript testing?

Regards,
Daniel P.


Re: How to get code coverage of Integration Test ?

2014-11-28 Thread Stephan Windmüller
On 28.01.2013, Julien Smadja wrote:

 And my problem is : *tapestry's components, pages, forms don't seem to be
 instrumented* because there is no coverage when watching in Sonar Report.
 
 I have a coverage percent for classes in packages like domain, but nothing
 in pages or components.

This post is rather old, but I stumpled upon this problem again and
thought about sharing a possible solution.

As explained in the FAQ[0] of Jacoco, there can be issues when classes
are changed in the application server, this changing the class id[1].
There are two possible solutions:

1. Specify a classdumpdir for the agent and use those classes for reporting.

2. Use offline instrumentation.

Both worked for me, but the first option produced duplicates of classes
which caused the reporting to fail.

Regards
 Stephan

[0] http://www.eclemma.org/jacoco/trunk/doc/faq.html
[1] http://www.eclemma.org/jacoco/trunk/doc/classids.html
[2] http://www.eclemma.org/jacoco/trunk/doc/offline.html

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How to get code coverage of Integration Test ?

2014-11-28 Thread Stephan Windmüller
On 29.01.2013, Lenny Primak wrote:

 Have you tried running in production mode?  That might work better. 

Just tested it, enabling production mode has no effect.

- Stephan

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Setup integration test with testng and tapestry services.

2014-08-29 Thread George Christman
Hi everyone, I'm trying to setup integration test with testng and tapestry
services. Lance kindly helped me get some of this up and running on my
personal project, but my day job is requiring a little bit more. So far I
have the following code. but experiencing the following two issues.

Issue 1. (SerializationSupport.java:38) - Setting a new service proxy
provider when there's already an existing provider. This may indicate that
you have multiple IoC Registries. (I'm aware of the cause, I just don't
know how to fix it)
Issue 2. The h2 in mem database doesn't clear between test, is there a way
to clear the data without having to session.delete() the content manually?

public class AppModuleTest {

public static void bind(ServiceBinder binder) {
binder.bind(SearchService.class, SearchServiceImpl.class);
binder.bind(UserInfoService.class, UserInfoServiceImpl.class);
}

public static Messages buildMessages() {
return Mockito.mock(Messages.class);
}

public static Request buildRequest() {
Request request = Mockito.mock(Request.class);
when(request.isXHR()).thenReturn(false);
return request;
}

public static void
contributeHibernateSessionSource(OrderedConfigurationHibernateConfigurer
configuration) {
configuration.add(test, new TestHibernateConfigurer());
configuration.addInstance(test, ETSSHibernateConfigurer.class);
}

public static void
contributeHibernateEntityPackageManager(org.apache.tapestry5.ioc.ConfigurationString
config) {
config.add(org.healthresearch.etss.entities);
}

@Scope(ScopeConstants.PERTHREAD)
public static FullTextSession
buildFullTextSession(HibernateSessionManager sessionManager) {
return Search.getFullTextSession(sessionManager.getSession());
}

public static void
contributeApplicationDefaults(MappedConfigurationString, Object config) {
config.add(HibernateSymbols.DEFAULT_CONFIGURATION, false);
}

}


public class TestHibernateConfigurer implements HibernateConfigurer {

@Override
public void configure(Configuration config) {
config.setProperty(hibernate.dialect,
org.hibernate.dialect.H2Dialect);
config.setProperty(hibernate.connection.driver_class,
org.h2.Driver);
config.setProperty(hibernate.connection.url, jdbc:h2:mem:test);
config.setProperty(hibernate.hbm2ddl.auto, update);
config.setProperty(hibernate.show_sql, false);
config.setProperty(hibernate.format_sql, true);
config.setProperty(hibernate.hbm2ddl.import_files, xxx);
config.setProperty(hibernate.search.default.directory_provider,
RAMDirectoryProvider.class.getName());
}

}


public abstract class AbstractHibernateTest {

private HibernateSessionManager sessionManager;
private SearchService searchService;
private Session session;

@BeforeClass
public void abstractBefore() {
System.out.println(abstractBefore);
Registry registry =
RegistryBuilder.buildAndStartupRegistry(AppModuleTest.class,
HibernateCoreModule.class);
this.sessionManager =
registry.getService(HibernateSessionManager.class);
this.searchService = registry.getService(SearchService.class);
this.session = sessionManager.getSession();
before(registry);
}

protected abstract void before(Registry registry) ;

public HibernateSessionManager getSessionManager() {
return sessionManager;
}

public Session getSession() {
return session;
}

public SearchService getSearchService() {
return searchService;
}

public void setDelete(Object object) {
session.delete(object);
sessionManager.commit();
}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

public void getCommit() {
session.flush();
sessionManager.commit();
}

}


public class SampleTest extends AbstractHibernateTest {

@Override
public void before(Registry registry) {
}

@Test
public void testDatabase() {
UserProfile userProfile = new UserProfile();
userProfile.setShortname(gmc07);
getSession().save(userProfile);

getCommit();

assertEquals(getResultSize(UserProfile.class), 1);

setDelete(userProfile);

assertEquals(getResultSize(UserProfile.class), 0);

}

}


public class ProfileTest extends AbstractHibernateTest {

@Override
protected void before(Registry registry) {
}

@Test
private void firstTest() {
UserProfile userProfile = new UserProfile();
userProfile.setShortname(jrr06);
getSession().save(userProfile);
getCommit();

getResultSize(UserProfile.class);
assertEquals(getResultSize(UserProfile.class), 1);

FullTextQuery query = getSearchService().search(UserProfile.class,
jrr06

Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread Kalle Korhonen
To nuke the H2 db, this is what I use (it's JPA, adjust for Hibernate):

// based on
http://www.objectpartners.com/2010/11/09/unit-testing-your-persistence-tier-code/
public void clearDatabase() throws SQLException {
EntityTransaction transaction = em.getTransaction();
if (!transaction.isActive()) transaction.begin();
Connection c = em.unwrap(Connection.class);
Statement s = c.createStatement();
s.execute(SET REFERENTIAL_INTEGRITY FALSE);
SetString tables = new HashSetString();
ResultSet rs = s.executeQuery(select table_name  + from
INFORMATION_SCHEMA.tables 
+ where table_type='TABLE' and table_schema='PUBLIC');
while (rs.next()) {
// if we don't skip over the sequence table, we'll start
getting The sequence table information is not complete
// exceptions
if (!rs.getString(1).startsWith(DUAL_) 
!rs.getString(1).equals(SEQUENCE)) {
tables.add(rs.getString(1));
}
}
rs.close();
for (String table : tables) {
s.executeUpdate(DELETE FROM  + table);
}
transaction.commit();
s.execute(SET REFERENTIAL_INTEGRITY TRUE);
s.close();
}

Kalle


On Fri, Aug 29, 2014 at 6:14 AM, George Christman gchrist...@cardaddy.com
wrote:

 Hi everyone, I'm trying to setup integration test with testng and tapestry
 services. Lance kindly helped me get some of this up and running on my
 personal project, but my day job is requiring a little bit more. So far I
 have the following code. but experiencing the following two issues.

 Issue 1. (SerializationSupport.java:38) - Setting a new service proxy
 provider when there's already an existing provider. This may indicate that
 you have multiple IoC Registries. (I'm aware of the cause, I just don't
 know how to fix it)
 Issue 2. The h2 in mem database doesn't clear between test, is there a way
 to clear the data without having to session.delete() the content manually?

 public class AppModuleTest {

 public static void bind(ServiceBinder binder) {
 binder.bind(SearchService.class, SearchServiceImpl.class);
 binder.bind(UserInfoService.class, UserInfoServiceImpl.class);
 }

 public static Messages buildMessages() {
 return Mockito.mock(Messages.class);
 }

 public static Request buildRequest() {
 Request request = Mockito.mock(Request.class);
 when(request.isXHR()).thenReturn(false);
 return request;
 }

 public static void
 contributeHibernateSessionSource(OrderedConfigurationHibernateConfigurer
 configuration) {
 configuration.add(test, new TestHibernateConfigurer());
 configuration.addInstance(test, ETSSHibernateConfigurer.class);
 }

 public static void

 contributeHibernateEntityPackageManager(org.apache.tapestry5.ioc.ConfigurationString
 config) {
 config.add(org.healthresearch.etss.entities);
 }

 @Scope(ScopeConstants.PERTHREAD)
 public static FullTextSession
 buildFullTextSession(HibernateSessionManager sessionManager) {
 return Search.getFullTextSession(sessionManager.getSession());
 }

 public static void
 contributeApplicationDefaults(MappedConfigurationString, Object config) {
 config.add(HibernateSymbols.DEFAULT_CONFIGURATION, false);
 }

 }


 public class TestHibernateConfigurer implements HibernateConfigurer {

 @Override
 public void configure(Configuration config) {
 config.setProperty(hibernate.dialect,
 org.hibernate.dialect.H2Dialect);
 config.setProperty(hibernate.connection.driver_class,
 org.h2.Driver);
 config.setProperty(hibernate.connection.url, jdbc:h2:mem:test);
 config.setProperty(hibernate.hbm2ddl.auto, update);
 config.setProperty(hibernate.show_sql, false);
 config.setProperty(hibernate.format_sql, true);
 config.setProperty(hibernate.hbm2ddl.import_files, xxx);
 config.setProperty(hibernate.search.default.directory_provider,
 RAMDirectoryProvider.class.getName());
 }

 }


 public abstract class AbstractHibernateTest {

 private HibernateSessionManager sessionManager;
 private SearchService searchService;
 private Session session;

 @BeforeClass
 public void abstractBefore() {
 System.out.println(abstractBefore);
 Registry registry =
 RegistryBuilder.buildAndStartupRegistry(AppModuleTest.class,
 HibernateCoreModule.class);
 this.sessionManager =
 registry.getService(HibernateSessionManager.class);
 this.searchService = registry.getService(SearchService.class);
 this.session = sessionManager.getSession();
 before(registry);
 }

 protected abstract void before(Registry registry) ;

 public HibernateSessionManager getSessionManager() {
 return sessionManager;
 }

 public Session getSession() {
 return session

Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread Lance Java
You should call registry.shutdown() in @AfterClass and
registry.cleanupThread() in @After.


Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread George Christman
Thanks guys for your input.

Lance, I tried the following configuration without success, but then tried
the second configuration and succeeded. Could you take a quick peak to be
sure I'm doing it correctly.

-- cleanup in @AfterMethod = This failed with the following exception
Failed: org.hibernate.SessionException: Session is closed
-- cleanup in @AfterTest = Failed:java.lang.IllegalStateException: Method
org.apache.tapestry5.ioc.internal.RegisteryImpl.cleanupThread(RegistryImpl.java.519)
may no longer be involked

-- I found success moving before to @BeforeMethod and moving registry
shutdown into @AfterMethod.

public class RegistryBuilderTest {

protected final Registry buildRegistry(Class... moduleClasses) {
RegistryBuilder builder = new RegistryBuilder();
builder.add(moduleClasses);
return builder.build();
}

}

public class SampleTest extends RegistryBuilderTest {

private Registry registry;
private HibernateSessionManager sessionManager;
private Session session;

@BeforeClass
protected void before() {
registry = buildRegistry(AppModuleTest.class,
HibernateCoreModule.class);
sessionManager = registry.getService(HibernateSessionManager.class);
session = sessionManager.getSession();
}

@Test
public void test1() {
System.out.println(test1);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test1);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);

}

@Test
public void test2() {
System.out.println(test2);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test2);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);

}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

@AfterClass
public void shutDown() {
System.out.println(shutDown);
registry.shutdown();
}

@AfterMethod
public void cleanupThread() {
System.out.println(cleanupThread);
registry.cleanupThread();
}

}





 Working configuration 


public class SampleTest extends RegistryBuilderTest {


private Registry registry;
private HibernateSessionManager sessionManager;
private Session session;

@BeforeMethod
protected void before() {
registry = buildRegistry(AppModuleTest.class,
HibernateCoreModule.class);
sessionManager = registry.getService(HibernateSessionManager.class);
session = sessionManager.getSession();
}

@Test
public void test1() {
System.out.println(test1);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test1);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);
}

@Test
public void test2() {
System.out.println(test2);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test2);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);
}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

@AfterMethod
public void cleanupThread() {
System.out.println(cleanupThread);
registry.cleanupThread();
registry.shutdown();
}

}



On Fri, Aug 29, 2014 at 11:33 AM, Lance Java lance.j...@googlemail.com
wrote:

 From the h2 docs here:
 http://www.h2database.com/html/features.html#in_memory_databases

 In some cases, only one connection to a in-memory database is required.
 This means the database to be opened is private. In this case, the database
 URL is jdbc:h2:mem: Opening two connections within the same virtual machine
 means opening two different (private) databases.

 Sometimes multiple connections to the same in-memory database are required.
 In this case, the database URL must include a name. Example:
 jdbc:h2:mem:db1. Accessing the same database using this URL only works
 within the same virtual machine and class loader environment.

 So, if you use a connection url of jdbc:h2:mem: AND you make sure to call
 registry.cleanupThread() in the @After of each test. You will get a new
 database for every test.




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
Hi George, you're lucky I know your architecture :) You should include a
snippet of the test module for completeness.

You'll notice the request is actually a mockito proxy setup in the @Before
of the test (in the test module).

Can you use @RequestParameter in the event (instead of
request.getParameter()?) then you can call the method and pass a value from
the test.

Otherwise you'll need to use mockito to mock request.getParameter(...)
(similar to how request.isXhr() is currently mocked). You'll need to be
careful here, there are 2 request proxies (mockito proxy wrapped by
tapestry ioc proxy). And I'm not sure mockito methods can act on the
tapestry proxy.
On 28 Aug 2014 02:47, George Christman gchrist...@cardaddy.com wrote:

 Hi everyone, I'm trying to create some unit test against a new component
 I'm working on. The new component uses request.getParameter(). I'm
 wondering how I would go about setting the request parameter in my test
 case.

 Component I'm testing

 public void keywordFacetSearch() {
 // Get the user's search keyword(s). Get optional parameters, or
 apply default values if those parameters weren't passed.
 String searchString = request.getParameter(SearchParam.KEY) != null
 ? request.getParameter(CarDaddyEnum.KEY).trim() : ;
 }

 Test case

 @Test
   public void testKeywordFacetSearch() {
 request.setAttribute(SearchParam.KEY, foo);
   }

 request.setAttribute doesn't seem to work. Any ideas?

 Thanks

 --
 George Christman
 www.CarDaddy.com
 P.O. Box 735
 Johnstown, New York



Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
An even simpler approach is to grab the request parameter in the page /
component and pass through to a service. Then forget about testing the page
/ component and focus on the service.

This is what I usually do. A couple of lines of code go untested but my api
is better and tests are much easier to maintain.


Re: Unit test component with request parameter

2014-08-28 Thread George Christman
Hi lance, I've been working on simplifying the design, so with that said
the service and page design is a little different from what I have checked
in. My goal is to remove all the request parameters from the page and put
them directly into the service so that I'm not having to pass them all over
the place.

So can I just add @Request Parameter to my service method signature and
both automatically read the request parameter from the url or just manually
pass it in through the the unit test? I'm not sure if thats what you were
suggesting.

I'm still very new to the mockito stuff, so I don't understand what it is
actually doing or how to use it.

I'm hoping to simplify the page class so that no testing is required.
Hopefully we can just test the services.
On Aug 28, 2014 3:18 AM, Lance Java lance.j...@googlemail.com wrote:

 An even simpler approach is to grab the request parameter in the page /
 component and pass through to a service. Then forget about testing the page
 / component and focus on the service.

 This is what I usually do. A couple of lines of code go untested but my api
 is better and tests are much easier to maintain.



Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
@RequestParameter will only work for page and component events.

A robust service layer should never reference the Request or any other web
objects so you should really pass them through to the service. Perhaps you
want to encapsulate multiple values in a bean which can grow over time
without changing the service's method signature.

Is there a reason why you are using request parameters and not field values
or event parameters?


Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
I'd do something like this to separate web from service and keep it
testable.

@Inject
private MyService myService;

public void doSearch(@RequestParam String filter1, @RequestParam Integer
filter2) {
   SearchFilter filter = new SearchFilter();
   filter.setFilter1(filter1);
   filter.setFilter2(filter2);

   ListSearchResult results = myService.doSearch(filter);
   doStuff(results);
}


Re: Unit test component with request parameter

2014-08-28 Thread George Christman
Ah okay, so I guess what you are suggesting is similar to what I originally
had. I'm not sure I understand the differences between field values and
event parameters. I just need to be able to read parameters from the URL.


On Thu, Aug 28, 2014 at 9:08 AM, Lance Java lance.j...@googlemail.com
wrote:

 I'd do something like this to separate web from service and keep it
 testable.

 @Inject
 private MyService myService;

 public void doSearch(@RequestParam String filter1, @RequestParam Integer
 filter2) {
SearchFilter filter = new SearchFilter();
filter.setFilter1(filter1);
filter.setFilter2(filter2);

ListSearchResult results = myService.doSearch(filter);
doStuff(results);
 }




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
 Im not sure I understand the differences between field values and event
parameters
field values - What I meant here was using a t:form / and binding
properties to TextField and Select etc.
event parameters - eg: onMyEvent(String param1, String param2, ...)

Have you seen the filter demo of the observe plugin in tapestry-stitch?
http://tapestry-stitch.uklance.cloudbees.net/observedemo
It hides request parameters from you and converts to event parameters so
your code can be cleaner.


Re: Unit test component with request parameter

2014-08-28 Thread George Christman
Wouldn't you still need to set the parameters to build the URL though? We
just need to be sure the filters remain in the URL so that the searches can
be book marked and indexed by search engines.


On Thu, Aug 28, 2014 at 10:46 AM, Lance Java lance.j...@googlemail.com
wrote:

  Im not sure I understand the differences between field values and event
 parameters
 field values - What I meant here was using a t:form / and binding
 properties to TextField and Select etc.
 event parameters - eg: onMyEvent(String param1, String param2, ...)

 Have you seen the filter demo of the observe plugin in tapestry-stitch?
 http://tapestry-stitch.uklance.cloudbees.net/observedemo
 It hides request parameters from you and converts to event parameters so
 your code can be cleaner.




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
I've been making assumptions without viewing code :) Up until now I've been
thinking it was an AJAX update.

I'm now thinking you're doing a redirect after post and you're using
request parameters to pass the values (avoiding @Persist and having
bookmarkable urls).

Sounds fine to me. The other option is to use activation context.


Re: Unit test component with request parameter

2014-08-28 Thread George Christman
Yup you got it :) I believe you were the one who use push me away from
@Persist and build stateless apps lol.


On Thu, Aug 28, 2014 at 12:24 PM, Lance Java lance.j...@googlemail.com
wrote:

 I've been making assumptions without viewing code :) Up until now I've been
 thinking it was an AJAX update.

 I'm now thinking you're doing a redirect after post and you're using
 request parameters to pass the values (avoiding @Persist and having
 bookmarkable urls).

 Sounds fine to me. The other option is to use activation context.




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
 I believe you were the one who use push me away from @Persist
Lol... sounds like me :)

I'm no SEO guru but I think keywords in the URL score better than request
parameters. You might be interested in this recent feature I added to
@PageActivationContext

https://issues.apache.org/jira/browse/TAP5-2138


Re: Unit test component with request parameter

2014-08-28 Thread George Christman
Your absolutely correct, context URLs are much better for SEO than request
parameters. I tend to use both at the same time, example
domain/category?make=ford, category being the context. I think what you've
done is a cool idea, however with the amount of filters that we will end up
having, it would get real messy when they are mostly all null. It would end
up looking something like this.
domain.com/category/make/$N/$N/$N/$N/$N/$N/$N/$N/$N/$N/brown

Some of the newer stuff I have planned will look something like this.
http://www.cardaddy.com/used-cars/2011-toyota-corolla-le-albany-ny-12205-4978?_rd=50color=brown

used-cars = context param
2011-toyota-corolla-le-albany-ny-12205-4978 = context param
12095 = zipcode
4978 = db pk for the year make model trim combo.

We are already doing something similar on a smaller scale here.
http://www.cardaddy.com/forsale/vehicle/2011-toyota-corolla-le-duluth-ga-4978


On Thu, Aug 28, 2014 at 2:14 PM, Lance Java lance.j...@googlemail.com
wrote:

  I believe you were the one who use push me away from @Persist
 Lol... sounds like me :)

 I'm no SEO guru but I think keywords in the URL score better than request
 parameters. You might be interested in this recent feature I added to
 @PageActivationContext

 https://issues.apache.org/jira/browse/TAP5-2138




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: Unit test component with request parameter

2014-08-28 Thread Thiago H de Paula Figueiredo
On Thu, 28 Aug 2014 16:27:20 -0300, George Christman  
gchrist...@cardaddy.com wrote:


Your absolutely correct, context URLs are much better for SEO than  
request

parameters. I tend to use both at the same time, example
domain/category?make=ford, category being the context. I think what  
you've
done is a cool idea, however with the amount of filters that we will end  
up
having, it would get real messy when they are mostly all null. It would  
end

up looking something like this.
domain.com/category/make/$N/$N/$N/$N/$N/$N/$N/$N/$N/$N/brown


You can avoid the $N by providing your own  
org.apache.tapestry5.services.URLEncoder.



Some of the newer stuff I have planned will look something like this.
http://www.cardaddy.com/used-cars/2011-toyota-corolla-le-albany-ny-12205-4978?_rd=50color=brown


You could also map the other parameters into a single string and pass it  
as an activation context value. In this case, you'd need to do the string  
- parameters map yourself.


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Unit test component with request parameter

2014-08-28 Thread Lance Java
Looks like you've put a lot of thought into your urls.

 It would end up looking something like this.
domain.com
http://domain.com/category/make/$N/$N/$N/$N/$N/$N/$N/$N/$N/$N/brown
/category/make/$N/$N/$N/$N/$N/$N/$N/$N/$N/$N/brown
http://domain.com/category/make/$N/$N/$N/$N/$N/$N/$N/$N/$N/$N/brown

Haha... yeah... It's not suited to this use case. It works better when
there can only be trailing nulls (which don't appear in the url).


Unit test component with request parameter

2014-08-27 Thread George Christman
Hi everyone, I'm trying to create some unit test against a new component
I'm working on. The new component uses request.getParameter(). I'm
wondering how I would go about setting the request parameter in my test
case.

Component I'm testing

public void keywordFacetSearch() {
// Get the user's search keyword(s). Get optional parameters, or
apply default values if those parameters weren't passed.
String searchString = request.getParameter(SearchParam.KEY) != null
? request.getParameter(CarDaddyEnum.KEY).trim() : ;
}

Test case

@Test
  public void testKeywordFacetSearch() {
request.setAttribute(SearchParam.KEY, foo);
  }

request.setAttribute doesn't seem to work. Any ideas?

Thanks

-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: How do you unit test services with dependent services

2014-01-22 Thread Lance Java
I think it would be easy enough to create a TapestryJUnit4ClassRunner which
is similar to SpringJUnit4ClassRunner.

eg:

@RunWith(TapestryJUnit4ClassRunner.class)
@Modules({SecurityModule.class, HibernateModule.class, MyTestModule.class})
@ModuleDefs({SpringModuleDef.class})
public class MyIOCTest {
   public static class MyTestModule {
  public static Foo buildFoo() { return new FooImmpl(); }
   }

   @Inject
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(fo.doStuff());
   }
}


Re: How do you unit test services with dependent services

2014-01-22 Thread Lance Java
You can use

IOCUtilities.addDefaultModules(RegistryBuilder)

To scan the classpath for META-INF entries.
On 21 Jan 2014 19:47, George Christman gchrist...@cardaddy.com wrote:

 and that is the easiest way to do it ugh lol


 On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski
 dragan.sahpa...@gmail.comwrote:

  You have to manually add ALL the tapestry IOC modules you're using (in
 this
  case the tapestry-security module
  org.tynamo.security.services.SecurityModule), because you're starting
 only
  the Registry and not the entire webapp.
 
  Cheers,
  Dragan Sahpaski
 
 
  On Tue, Jan 21, 2014 at 8:22 PM, George Christman
  gchrist...@cardaddy.comwrote:
 
   Dmitry, I'm very confused. I use constructor injection in my services
  which
   I always thought was the correct way to do it based on the tap docs.
  
   I have the following test class where I'm trying to use a service.
  
   public class TimeSheetServiceTest {
  
   protected static TimeSheetService timeSheetService;
  
   @BeforeClass
   public static void setup() {
   Registry registry;
   RegistryBuilder builder = new RegistryBuilder();
   builder.add(AppModule.class);
   registry = builder.build();
   registry.performRegistryStartup();
   timeSheetService = registry.getService(TimeSheetService.class);
   }
  
   @Test
   public void testService() {
   int result =
  
 
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
   System.out.println(result  + result);
   }
  
   }
  
   TimeSheetService injects another service called UserInfoService
 userInfo
   like so,
  
   public class TimeSheetServiceImpl implements TimeSheetService {
  
   public TimeSheetServiceImpl(UserInfoService userInfo) {
   this.userInfo = userInfo;
   }
  
   }
  
   When I try running my test class, I get the following exception.
  
   ?xml version=1.0 encoding=UTF-8?
  
   !-- Generated by org.testng.reporters.JUnitReportReporter --
   -testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58
 GMT
   failures=1 tests=1
   name=org.domain.etss.services.form.TimeSheetServiceTest
   hostname=hri185169
   !-- org.domain.etss.services.form.TimeSheetServiceTest --
   -testcase time=0.000 name=testService
  
 classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
   message=Contribution
  
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
   SecurityFilterChainFactory) (at AppModule.java:312) is for service
   'SecurityConfiguration', which does not exist.
   type=java.lang.IllegalArgumentException
   ![CDATA[java.lang.IllegalArgumentException: Contribution
  
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
   SecurityFilterChainFactory) (at AppModule.java:312) is for service
   'SecurityConfiguration', which does not exist. at
  
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
   at
  
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
   at
  org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
   at
  
  
 
 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
  
  
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at
  
  
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601) at
  
  
 
 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
   at
  org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
   at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
 at
   org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at
  
  
 
 org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
   at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
 at
   org.testng.TestRunner.privateRun(TestRunner.java:768) at
   org.testng.TestRunner.run(TestRunner.java:617) at
   org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
   org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
   org.testng.SuiteRunner.run(SuiteRunner.java:240) at
   org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at
   org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at
   org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) at
   org.testng.TestNG.runSuitesLocally(TestNG.java:1113) at
   org.testng.TestNG.run(TestNG.java:1025) at
  
 
 org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
   at
  
  
 
 org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:88

How do you unit test services with dependent services

2014-01-21 Thread George Christman
Hello, we are trying to unit test our services, but our services contain
other injected services. I'm wondering how you test injected services. Is
there a configuration I'm missing?

-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Re: How do you unit test services with dependent services

2014-01-21 Thread Nourredine K.
Hi,

Just use the 
PageTester#getServicehttp://tapestry.apache.org/current/apidocs/org/apache/tapestry5/test/PageTester.html#getService%28java.lang.Class%29method
in your unit tests.




2014/1/21 George Christman gchrist...@cardaddy.com

 Hello, we are trying to unit test our services, but our services contain
 other injected services. I'm wondering how you test injected services. Is
 there a configuration I'm missing?

 --
 George Christman
 www.CarDaddy.com
 P.O. Box 735
 Johnstown, New York



Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
I usually create base class where I construct registry instance, then I use
registry.getService(Intf.class) when I need an instance of a service.

Like here:
https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-quartz/src/test/java/com/anjlab/tapestry5/services/quartz/SchedulerTest.java


On Tue, Jan 21, 2014 at 9:07 PM, George Christman
gchrist...@cardaddy.comwrote:

 Hello, we are trying to unit test our services, but our services contain
 other injected services. I'm wondering how you test injected services. Is
 there a configuration I'm missing?

 --
 George Christman
 www.CarDaddy.com
 P.O. Box 735
 Johnstown, New York




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
I agree with Dimitry but thats more for integration like testing.
For basic unit testing of services methods (usually we unit test a single
method per test) we mock the dependencies (the injected services) and pass
the mocks through the constructor of the service implementation class under
test. That's why we prefer constructor based injection.

If we need to mock methods in the service that's being bested than we
usually use Spy in Spock or the equivalent feature in other mock frameworks.

Cheers,
Dragan Sahpaski


On Tue, Jan 21, 2014 at 6:34 PM, Dmitry Gusev dmitry.gu...@gmail.comwrote:

 I usually create base class where I construct registry instance, then I use
 registry.getService(Intf.class) when I need an instance of a service.

 Like here:

 https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-quartz/src/test/java/com/anjlab/tapestry5/services/quartz/SchedulerTest.java


 On Tue, Jan 21, 2014 at 9:07 PM, George Christman
 gchrist...@cardaddy.comwrote:

  Hello, we are trying to unit test our services, but our services contain
  other injected services. I'm wondering how you test injected services. Is
  there a configuration I'm missing?
 
  --
  George Christman
  www.CarDaddy.com
  P.O. Box 735
  Johnstown, New York
 



 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com



Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
Here's one recent thread that on the same subject:
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Testing-Tapestry-td5723590.html


On Tue, Jan 21, 2014 at 9:41 PM, Dragan Sahpaski
dragan.sahpa...@gmail.comwrote:

 I agree with Dimitry but thats more for integration like testing.
 For basic unit testing of services methods (usually we unit test a single
 method per test) we mock the dependencies (the injected services) and pass
 the mocks through the constructor of the service implementation class under
 test. That's why we prefer constructor based injection.

 If we need to mock methods in the service that's being bested than we
 usually use Spy in Spock or the equivalent feature in other mock
 frameworks.

 Cheers,
 Dragan Sahpaski


 On Tue, Jan 21, 2014 at 6:34 PM, Dmitry Gusev dmitry.gu...@gmail.com
 wrote:

  I usually create base class where I construct registry instance, then I
 use
  registry.getService(Intf.class) when I need an instance of a service.
 
  Like here:
 
 
 https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-quartz/src/test/java/com/anjlab/tapestry5/services/quartz/SchedulerTest.java
 
 
  On Tue, Jan 21, 2014 at 9:07 PM, George Christman
  gchrist...@cardaddy.comwrote:
 
   Hello, we are trying to unit test our services, but our services
 contain
   other injected services. I'm wondering how you test injected services.
 Is
   there a configuration I'm missing?
  
   --
   George Christman
   www.CarDaddy.com
   P.O. Box 735
   Johnstown, New York
  
 
 
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
Right, this is for integration testing. I use mocking too, but rarely -- my
tests are 80% integration ones and involve DB (the same as in production).
For mocks I have to use constructor injection also, and this is the only
reason why I use constructor injections.
The code looks ugly in this cases, though, when you have more than 5
dependencies per service. And it's also a tedious task when you want to add
another dependency to the service, because you have to update all test
clients also. That's why I prefer @Inject.

It would be nice to have some api to override, decorate, and advise some
services on existing (built) registry instance right in the test method.
Maybe (temporarily) replace some service with a mock. So that I won't have
to build new module just to override one service for one test case, because
it requires additional setup. Just a thoughts.


On Tue, Jan 21, 2014 at 9:41 PM, Dragan Sahpaski
dragan.sahpa...@gmail.comwrote:

 I agree with Dimitry but thats more for integration like testing.
 For basic unit testing of services methods (usually we unit test a single
 method per test) we mock the dependencies (the injected services) and pass
 the mocks through the constructor of the service implementation class under
 test. That's why we prefer constructor based injection.

 If we need to mock methods in the service that's being bested than we
 usually use Spy in Spock or the equivalent feature in other mock
 frameworks.

 Cheers,
 Dragan Sahpaski


 On Tue, Jan 21, 2014 at 6:34 PM, Dmitry Gusev dmitry.gu...@gmail.com
 wrote:

  I usually create base class where I construct registry instance, then I
 use
  registry.getService(Intf.class) when I need an instance of a service.
 
  Like here:
 
 
 https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-quartz/src/test/java/com/anjlab/tapestry5/services/quartz/SchedulerTest.java
 
 
  On Tue, Jan 21, 2014 at 9:07 PM, George Christman
  gchrist...@cardaddy.comwrote:
 
   Hello, we are trying to unit test our services, but our services
 contain
   other injected services. I'm wondering how you test injected services.
 Is
   there a configuration I'm missing?
  
   --
   George Christman
   www.CarDaddy.com
   P.O. Box 735
   Johnstown, New York
  
 
 
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
Dmitry, I'm very confused. I use constructor injection in my services which
I always thought was the correct way to do it based on the tap docs.

I have the following test class where I'm trying to use a service.

public class TimeSheetServiceTest {

protected static TimeSheetService timeSheetService;

@BeforeClass
public static void setup() {
Registry registry;
RegistryBuilder builder = new RegistryBuilder();
builder.add(AppModule.class);
registry = builder.build();
registry.performRegistryStartup();
timeSheetService = registry.getService(TimeSheetService.class);
}

@Test
public void testService() {
int result =
timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
System.out.println(result  + result);
}

}

TimeSheetService injects another service called UserInfoService userInfo
like so,

public class TimeSheetServiceImpl implements TimeSheetService {

public TimeSheetServiceImpl(UserInfoService userInfo) {
this.userInfo = userInfo;
}

}

When I try running my test class, I get the following exception.

?xml version=1.0 encoding=UTF-8?

!-- Generated by org.testng.reporters.JUnitReportReporter --
-testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58 GMT
failures=1 tests=1
name=org.domain.etss.services.form.TimeSheetServiceTest
hostname=hri185169
!-- org.domain.etss.services.form.TimeSheetServiceTest --
-testcase time=0.000 name=testService
classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
message=Contribution
org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
SecurityFilterChainFactory) (at AppModule.java:312) is for service
'SecurityConfiguration', which does not exist.
type=java.lang.IllegalArgumentException
![CDATA[java.lang.IllegalArgumentException: Contribution
org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
SecurityFilterChainFactory) (at AppModule.java:312) is for service
'SecurityConfiguration', which does not exist. at
org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
at
org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
at org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
at
org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601) at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at
org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at
org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at
org.testng.TestRunner.privateRun(TestRunner.java:768) at
org.testng.TestRunner.run(TestRunner.java:617) at
org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
org.testng.SuiteRunner.run(SuiteRunner.java:240) at
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at
org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) at
org.testng.TestNG.runSuitesLocally(TestNG.java:1113) at
org.testng.TestNG.run(TestNG.java:1025) at
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
at
org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:88)
at
org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601) at
org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at com.sun.proxy.$Proxy0.invoke(Unknown Source) at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
]]
/failure/testcase
!-- testService --
/testsuite

From this line

public static void
contributeSecurityConfiguration(ConfigurationSecurityFilterChain
configuration,

SecurityFilterChainFactory factory) {

configuration.add

Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
You have to manually add ALL the tapestry IOC modules you're using (in this
case the tapestry-security module
org.tynamo.security.services.SecurityModule), because you're starting only
the Registry and not the entire webapp.

Cheers,
Dragan Sahpaski


On Tue, Jan 21, 2014 at 8:22 PM, George Christman
gchrist...@cardaddy.comwrote:

 Dmitry, I'm very confused. I use constructor injection in my services which
 I always thought was the correct way to do it based on the tap docs.

 I have the following test class where I'm trying to use a service.

 public class TimeSheetServiceTest {

 protected static TimeSheetService timeSheetService;

 @BeforeClass
 public static void setup() {
 Registry registry;
 RegistryBuilder builder = new RegistryBuilder();
 builder.add(AppModule.class);
 registry = builder.build();
 registry.performRegistryStartup();
 timeSheetService = registry.getService(TimeSheetService.class);
 }

 @Test
 public void testService() {
 int result =
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
 System.out.println(result  + result);
 }

 }

 TimeSheetService injects another service called UserInfoService userInfo
 like so,

 public class TimeSheetServiceImpl implements TimeSheetService {

 public TimeSheetServiceImpl(UserInfoService userInfo) {
 this.userInfo = userInfo;
 }

 }

 When I try running my test class, I get the following exception.

 ?xml version=1.0 encoding=UTF-8?

 !-- Generated by org.testng.reporters.JUnitReportReporter --
 -testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58 GMT
 failures=1 tests=1
 name=org.domain.etss.services.form.TimeSheetServiceTest
 hostname=hri185169
 !-- org.domain.etss.services.form.TimeSheetServiceTest --
 -testcase time=0.000 name=testService
 classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
 message=Contribution

 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
 SecurityFilterChainFactory) (at AppModule.java:312) is for service
 'SecurityConfiguration', which does not exist.
 type=java.lang.IllegalArgumentException
 ![CDATA[java.lang.IllegalArgumentException: Contribution

 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
 SecurityFilterChainFactory) (at AppModule.java:312) is for service
 'SecurityConfiguration', which does not exist. at

 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
 at

 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
 at org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
 at

 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at

 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601) at

 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
 at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
 at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at
 org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at

 org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at
 org.testng.TestRunner.privateRun(TestRunner.java:768) at
 org.testng.TestRunner.run(TestRunner.java:617) at
 org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
 org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
 org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
 org.testng.SuiteRunner.run(SuiteRunner.java:240) at
 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at
 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at
 org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) at
 org.testng.TestNG.runSuitesLocally(TestNG.java:1113) at
 org.testng.TestNG.run(TestNG.java:1025) at
 org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
 at

 org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:88)
 at

 org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at

 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at

 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601) at

 org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
 at com.sun.proxy.$Proxy0.invoke(Unknown Source) at

 org.apache.maven.surefire.booter.SurefireStarter.invokeProvider

Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
and that is the easiest way to do it ugh lol


On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski
dragan.sahpa...@gmail.comwrote:

 You have to manually add ALL the tapestry IOC modules you're using (in this
 case the tapestry-security module
 org.tynamo.security.services.SecurityModule), because you're starting only
 the Registry and not the entire webapp.

 Cheers,
 Dragan Sahpaski


 On Tue, Jan 21, 2014 at 8:22 PM, George Christman
 gchrist...@cardaddy.comwrote:

  Dmitry, I'm very confused. I use constructor injection in my services
 which
  I always thought was the correct way to do it based on the tap docs.
 
  I have the following test class where I'm trying to use a service.
 
  public class TimeSheetServiceTest {
 
  protected static TimeSheetService timeSheetService;
 
  @BeforeClass
  public static void setup() {
  Registry registry;
  RegistryBuilder builder = new RegistryBuilder();
  builder.add(AppModule.class);
  registry = builder.build();
  registry.performRegistryStartup();
  timeSheetService = registry.getService(TimeSheetService.class);
  }
 
  @Test
  public void testService() {
  int result =
 
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
  System.out.println(result  + result);
  }
 
  }
 
  TimeSheetService injects another service called UserInfoService userInfo
  like so,
 
  public class TimeSheetServiceImpl implements TimeSheetService {
 
  public TimeSheetServiceImpl(UserInfoService userInfo) {
  this.userInfo = userInfo;
  }
 
  }
 
  When I try running my test class, I get the following exception.
 
  ?xml version=1.0 encoding=UTF-8?
 
  !-- Generated by org.testng.reporters.JUnitReportReporter --
  -testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58 GMT
  failures=1 tests=1
  name=org.domain.etss.services.form.TimeSheetServiceTest
  hostname=hri185169
  !-- org.domain.etss.services.form.TimeSheetServiceTest --
  -testcase time=0.000 name=testService
  classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
  message=Contribution
 
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
  SecurityFilterChainFactory) (at AppModule.java:312) is for service
  'SecurityConfiguration', which does not exist.
  type=java.lang.IllegalArgumentException
  ![CDATA[java.lang.IllegalArgumentException: Contribution
 
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
  SecurityFilterChainFactory) (at AppModule.java:312) is for service
  'SecurityConfiguration', which does not exist. at
 
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
  at
 
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
  at
 org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
  at
 
 
 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at
 
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601) at
 
 
 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
  at
 org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
  at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at
  org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at
 
 
 org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at
  org.testng.TestRunner.privateRun(TestRunner.java:768) at
  org.testng.TestRunner.run(TestRunner.java:617) at
  org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
  org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
  org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
  org.testng.SuiteRunner.run(SuiteRunner.java:240) at
  org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at
  org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at
  org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) at
  org.testng.TestNG.runSuitesLocally(TestNG.java:1113) at
  org.testng.TestNG.run(TestNG.java:1025) at
 
 org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
  at
 
 
 org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:88)
  at
 
 
 org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at
 
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43

Re: How do you unit test services with dependent services

2014-01-21 Thread George Christman
Am I going about this all the wrong way? Am I using the services correctly?
I never see in any example test code where you guys are having to add all
the modules. Any suggestions?


On Tue, Jan 21, 2014 at 2:47 PM, George Christman
gchrist...@cardaddy.comwrote:

 and that is the easiest way to do it ugh lol


 On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski 
 dragan.sahpa...@gmail.com wrote:

 You have to manually add ALL the tapestry IOC modules you're using (in
 this
 case the tapestry-security module
 org.tynamo.security.services.SecurityModule), because you're starting only
 the Registry and not the entire webapp.

 Cheers,
 Dragan Sahpaski


 On Tue, Jan 21, 2014 at 8:22 PM, George Christman
 gchrist...@cardaddy.comwrote:

  Dmitry, I'm very confused. I use constructor injection in my services
 which
  I always thought was the correct way to do it based on the tap docs.
 
  I have the following test class where I'm trying to use a service.
 
  public class TimeSheetServiceTest {
 
  protected static TimeSheetService timeSheetService;
 
  @BeforeClass
  public static void setup() {
  Registry registry;
  RegistryBuilder builder = new RegistryBuilder();
  builder.add(AppModule.class);
  registry = builder.build();
  registry.performRegistryStartup();
  timeSheetService = registry.getService(TimeSheetService.class);
  }
 
  @Test
  public void testService() {
  int result =
 
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
  System.out.println(result  + result);
  }
 
  }
 
  TimeSheetService injects another service called UserInfoService userInfo
  like so,
 
  public class TimeSheetServiceImpl implements TimeSheetService {
 
  public TimeSheetServiceImpl(UserInfoService userInfo) {
  this.userInfo = userInfo;
  }
 
  }
 
  When I try running my test class, I get the following exception.
 
  ?xml version=1.0 encoding=UTF-8?
 
  !-- Generated by org.testng.reporters.JUnitReportReporter --
  -testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58 GMT
  failures=1 tests=1
  name=org.domain.etss.services.form.TimeSheetServiceTest
  hostname=hri185169
  !-- org.domain.etss.services.form.TimeSheetServiceTest --
  -testcase time=0.000 name=testService
  classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
  message=Contribution
 
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
  SecurityFilterChainFactory) (at AppModule.java:312) is for service
  'SecurityConfiguration', which does not exist.
  type=java.lang.IllegalArgumentException
  ![CDATA[java.lang.IllegalArgumentException: Contribution
 
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
  SecurityFilterChainFactory) (at AppModule.java:312) is for service
  'SecurityConfiguration', which does not exist. at
 
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
  at
 
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
  at
 org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
  at
 
 
 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
 
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at
 
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601) at
 
 
 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
  at
 org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
  at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at
  org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at
 
 
 org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
  at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
 at
  org.testng.TestRunner.privateRun(TestRunner.java:768) at
  org.testng.TestRunner.run(TestRunner.java:617) at
  org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
  org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
  org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
  org.testng.SuiteRunner.run(SuiteRunner.java:240) at
  org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at
  org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87) at
  org.testng.TestNG.runSuitesSequentially(TestNG.java:1188) at
  org.testng.TestNG.runSuitesLocally(TestNG.java:1113) at
  org.testng.TestNG.run(TestNG.java:1025) at
 
 org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
  at
 
 
 org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:88)
  at
 
 
 org.apache.maven.surefire.testng.TestNGProvider.invoke

Re: How do you unit test services with dependent services

2014-01-21 Thread Dmitry Gusev
As Dragan said, you have to add all modules manually.
In the thread I've posted a link to above you can find some references,
like here:

https://gist.github.com/dmitrygusev/6672859#file-baseintegrationtest-java-L11-L18

Notice, the class also extends AbstractShiroTest, because some additional
setup required for shiro and unit testing.


On Tue, Jan 21, 2014 at 11:59 PM, George Christman
gchrist...@cardaddy.comwrote:

 Am I going about this all the wrong way? Am I using the services correctly?
 I never see in any example test code where you guys are having to add all
 the modules. Any suggestions?


 On Tue, Jan 21, 2014 at 2:47 PM, George Christman
 gchrist...@cardaddy.comwrote:

  and that is the easiest way to do it ugh lol
 
 
  On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski 
  dragan.sahpa...@gmail.com wrote:
 
  You have to manually add ALL the tapestry IOC modules you're using (in
  this
  case the tapestry-security module
  org.tynamo.security.services.SecurityModule), because you're starting
 only
  the Registry and not the entire webapp.
 
  Cheers,
  Dragan Sahpaski
 
 
  On Tue, Jan 21, 2014 at 8:22 PM, George Christman
  gchrist...@cardaddy.comwrote:
 
   Dmitry, I'm very confused. I use constructor injection in my services
  which
   I always thought was the correct way to do it based on the tap docs.
  
   I have the following test class where I'm trying to use a service.
  
   public class TimeSheetServiceTest {
  
   protected static TimeSheetService timeSheetService;
  
   @BeforeClass
   public static void setup() {
   Registry registry;
   RegistryBuilder builder = new RegistryBuilder();
   builder.add(AppModule.class);
   registry = builder.build();
   registry.performRegistryStartup();
   timeSheetService =
 registry.getService(TimeSheetService.class);
   }
  
   @Test
   public void testService() {
   int result =
  
 
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
   System.out.println(result  + result);
   }
  
   }
  
   TimeSheetService injects another service called UserInfoService
 userInfo
   like so,
  
   public class TimeSheetServiceImpl implements TimeSheetService {
  
   public TimeSheetServiceImpl(UserInfoService userInfo) {
   this.userInfo = userInfo;
   }
  
   }
  
   When I try running my test class, I get the following exception.
  
   ?xml version=1.0 encoding=UTF-8?
  
   !-- Generated by org.testng.reporters.JUnitReportReporter --
   -testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58
 GMT
   failures=1 tests=1
   name=org.domain.etss.services.form.TimeSheetServiceTest
   hostname=hri185169
   !-- org.domain.etss.services.form.TimeSheetServiceTest --
   -testcase time=0.000 name=testService
  
 classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
   message=Contribution
  
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
   SecurityFilterChainFactory) (at AppModule.java:312) is for service
   'SecurityConfiguration', which does not exist.
   type=java.lang.IllegalArgumentException
   ![CDATA[java.lang.IllegalArgumentException: Contribution
  
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
   SecurityFilterChainFactory) (at AppModule.java:312) is for service
   'SecurityConfiguration', which does not exist. at
  
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
   at
  
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
   at
  org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
   at
  
  
 
 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
  
  
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at
  
  
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601) at
  
  
 
 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
   at
  org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:551)
   at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
 at
   org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at
  
  
 
 org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175)
   at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107)
  at
   org.testng.TestRunner.privateRun(TestRunner.java:768) at
   org.testng.TestRunner.run(TestRunner.java:617) at
   org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at
   org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at
   org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at
   org.testng.SuiteRunner.run

Re: How do you unit test services with dependent services

2014-01-21 Thread Dragan Sahpaski
Alternatively use the @SubModule in your AppModule which is not needed for
a webapp because when starting the tapestry filter, tapestry autoloads the
ioc modules for all jars on the classpath. This is very well documented
here http://tapestry.apache.org/autoloading-modules.html

You can see the code that does this in TapestryAppInitializer.java which
uses IOCUtilities.addDefaultModules to add the ioc modules (which you can
try also if you want to avoid specifying each module manually).

Cheers,
Dragan Sahpaski


On Tue, Jan 21, 2014 at 9:04 PM, Dmitry Gusev dmitry.gu...@gmail.comwrote:

 As Dragan said, you have to add all modules manually.
 In the thread I've posted a link to above you can find some references,
 like here:


 https://gist.github.com/dmitrygusev/6672859#file-baseintegrationtest-java-L11-L18

 Notice, the class also extends AbstractShiroTest, because some additional
 setup required for shiro and unit testing.


 On Tue, Jan 21, 2014 at 11:59 PM, George Christman
 gchrist...@cardaddy.comwrote:

  Am I going about this all the wrong way? Am I using the services
 correctly?
  I never see in any example test code where you guys are having to add all
  the modules. Any suggestions?
 
 
  On Tue, Jan 21, 2014 at 2:47 PM, George Christman
  gchrist...@cardaddy.comwrote:
 
   and that is the easiest way to do it ugh lol
  
  
   On Tue, Jan 21, 2014 at 2:30 PM, Dragan Sahpaski 
   dragan.sahpa...@gmail.com wrote:
  
   You have to manually add ALL the tapestry IOC modules you're using (in
   this
   case the tapestry-security module
   org.tynamo.security.services.SecurityModule), because you're starting
  only
   the Registry and not the entire webapp.
  
   Cheers,
   Dragan Sahpaski
  
  
   On Tue, Jan 21, 2014 at 8:22 PM, George Christman
   gchrist...@cardaddy.comwrote:
  
Dmitry, I'm very confused. I use constructor injection in my
 services
   which
I always thought was the correct way to do it based on the tap docs.
   
I have the following test class where I'm trying to use a service.
   
public class TimeSheetServiceTest {
   
protected static TimeSheetService timeSheetService;
   
@BeforeClass
public static void setup() {
Registry registry;
RegistryBuilder builder = new RegistryBuilder();
builder.add(AppModule.class);
registry = builder.build();
registry.performRegistryStartup();
timeSheetService =
  registry.getService(TimeSheetService.class);
}
   
@Test
public void testService() {
int result =
   
  
 
 timeSheetService.getHolidayListForPayPeriod(Calendar.getInstance()).size();
System.out.println(result  + result);
}
   
}
   
TimeSheetService injects another service called UserInfoService
  userInfo
like so,
   
public class TimeSheetServiceImpl implements TimeSheetService {
   
public TimeSheetServiceImpl(UserInfoService userInfo) {
this.userInfo = userInfo;
}
   
}
   
When I try running my test class, I get the following exception.
   
?xml version=1.0 encoding=UTF-8?
   
!-- Generated by org.testng.reporters.JUnitReportReporter --
-testsuite errors=0 time=0.000 timestamp=21 Jan 2014 19:18:58
  GMT
failures=1 tests=1
name=org.domain.etss.services.form.TimeSheetServiceTest
hostname=hri185169
!-- org.domain.etss.services.form.TimeSheetServiceTest --
-testcase time=0.000 name=testService
   
  classname=org.domain.etss.services.form.TimeSheetServiceTest-failure
message=Contribution
   
   
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
SecurityFilterChainFactory) (at AppModule.java:312) is for service
'SecurityConfiguration', which does not exist.
type=java.lang.IllegalArgumentException
![CDATA[java.lang.IllegalArgumentException: Contribution
   
   
  
 
 org.domain.etss.services.AppModule.contributeSecurityConfiguration(Configuration,
SecurityFilterChainFactory) (at AppModule.java:312) is for service
'SecurityConfiguration', which does not exist. at
   
   
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.validateContributeDefs(RegistryImpl.java:236)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.init(RegistryImpl.java:200)
at
  
 org.apache.tapestry5.ioc.RegistryBuilder.build(RegistryBuilder.java:170)
at
   
   
  
 
 org.domain.etss.services.form.TimeSheetServiceTest.setup(TimeSheetServiceTest.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
   
   
  
 
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
   
   
  
 
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601) at
   
   
  
 
 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80

Strange behavior with JUnit and MVN test in Eclipse

2013-11-29 Thread Alessio Gambi
Hi list !

I had a strange situation today that might deserve some more investigation (or 
at least a warning for those like me...).

Here it goes:

I created a plain service (List/Ordered contribs) via build* method
I created a contribution method to that service (List/Ordered contribs) via 
contribute* method

 I forgot to add an ID to one of my contribution using addInstance method. 
 Actually I used the empty string:
userContribution.addInstance(, ...) 

I wrote a test to start the registry, get an instance of the service, use the 
service, and check the results.
I run the test and magically it worked fine.

The I tried to deploy my artifact via mvn clean ... deploy
This triggered mvn test
And this time I got an exception in building the very same service (see output 
snippet below).


I am really curios to understand what's going on, and at the same time, I 
suggest the other non-black-belts like me to pay attention to this thing.

Thanks

-- Alessio



===
 Error invoking service contribution method 
at.ac.tuwien.dsg.cloud.modules.CloudAppModule.contributeBashUserDataService(OrderedConfiguration):
 java.lang.AssertionError
2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - 
Operations trace:
2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [ 1] 
Instantiating service BashUserDataService implementation via 
at.ac.tuwien.dsg.cloud.modules.CloudAppModule.buildBashUserDataService(Logger, 
PipelineBuilder, File, List) (at CloudAppModule.java:164)
2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [ 2] 
Creating plan to invoke public static 
at.ac.tuwien.dsg.cloud.services.UserDataService 
at.ac.tuwien.dsg.cloud.modules.CloudAppModule.buildBashUserDataService(org.slf4j.Logger,org.apache.tapestry5.ioc.services.PipelineBuilder,java.io.File,java.util.List)
2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [ 3] 
Determining injection value for parameter #4 (java.util.List)
2013-11-29 18:42:13,877 [main] ERROR org.apache.tapestry5.ioc.Registry - [ 4] 
Collecting ordered configuration for service BashUserDataService
2013-11-29 18:42:13,877 [main] ERROR org.apache.tapestry5.ioc.Registry - [ 5] 
Invoking 
at.ac.tuwien.dsg.cloud.modules.CloudAppModule.contributeBashUserDataService(OrderedConfiguration)
 (at CloudAppModule.java:217)
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.993 sec  
FAILURE!



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Strange behavior with JUnit and MVN test in Eclipse

2013-11-29 Thread Lance Java
Taking an educated stab in the dark here but maybe your using the m2e
plugin in eclipse and it's resolving one of your dependencies to another
project in eclipse

At the command line it's resolving the same dependency from your maven
repo.
 On 29 Nov 2013 17:52, Alessio Gambi alessioga...@gmail.com wrote:

 Hi list !

 I had a strange situation today that might deserve some more investigation
 (or at least a warning for those like me...).

 Here it goes:

 I created a plain service (List/Ordered contribs) via build* method
 I created a contribution method to that service (List/Ordered contribs)
 via contribute* method

  I forgot to add an ID to one of my contribution using addInstance
 method. Actually I used the empty string:
 userContribution.addInstance(, ...) 

 I wrote a test to start the registry, get an instance of the service, use
 the service, and check the results.
 I run the test and magically it worked fine.

 The I tried to deploy my artifact via mvn clean ... deploy
 This triggered mvn test
 And this time I got an exception in building the very same service (see
 output snippet below).


 I am really curios to understand what's going on, and at the same time, I
 suggest the other non-black-belts like me to pay attention to this thing.

 Thanks

 -- Alessio




 ===
  Error invoking service contribution method
 at.ac.tuwien.dsg.cloud.modules.CloudAppModule.contributeBashUserDataService(OrderedConfiguration):
 java.lang.AssertionError
 2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry -
 Operations trace:
 2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [
 1] Instantiating service BashUserDataService implementation via
 at.ac.tuwien.dsg.cloud.modules.CloudAppModule.buildBashUserDataService(Logger,
 PipelineBuilder, File, List) (at CloudAppModule.java:164)
 2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [
 2] Creating plan to invoke public static
 at.ac.tuwien.dsg.cloud.services.UserDataService
 at.ac.tuwien.dsg.cloud.modules.CloudAppModule.buildBashUserDataService(org.slf4j.Logger,org.apache.tapestry5.ioc.services.PipelineBuilder,java.io.File,java.util.List)
 2013-11-29 18:42:13,876 [main] ERROR org.apache.tapestry5.ioc.Registry - [
 3] Determining injection value for parameter #4 (java.util.List)
 2013-11-29 18:42:13,877 [main] ERROR org.apache.tapestry5.ioc.Registry - [
 4] Collecting ordered configuration for service BashUserDataService
 2013-11-29 18:42:13,877 [main] ERROR org.apache.tapestry5.ioc.Registry - [
 5] Invoking
 at.ac.tuwien.dsg.cloud.modules.CloudAppModule.contributeBashUserDataService(OrderedConfiguration)
 (at CloudAppModule.java:217)
 Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.993 sec
  FAILURE!



 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: Datatables warning when using t:if test....

2013-10-25 Thread Steve
Thanks for getting back to us - Glad it helped! I'm regularly asking
questions here myself so I'm just happy I was able to help someone
else :D.

Have a good weekend,


On 25 October 2013 05:08, lidijaldo . lidija@gmail.com wrote:
 Will keep that in mind, thanks!

 Regards,
 Lidija


 On Thu, Oct 24, 2013 at 5:46 PM, Lance Java lance.j...@googlemail.comwrote:

 Note that @Import can also be placed on render methods (eg setupRender)
 instead of annotating at the class level. If used on a render method, the
 import will only happen when the component is actually rendered. This might
 be cleaner in this case.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Datatables warning when using t:if test....

2013-10-24 Thread lidijaldo .
I tried importJavaScriptLibrary and it is really done dynamically.

I did what you proposed:

@Inject @Path(context:js/jquery-ui-1.8.19.custom.min.js)
protected Asset jqueryUi;
 @Inject @Path(context:js/TableTools.js)
protected Asset tableTools;
 @Inject @Path(context:js/dataTables.editor.min.js)
protected Asset dataTablesEditorMin;
 @Inject @Path(context:js/dataTables.editor.commons.js)
protected Asset dataTablesEditorCommons;


In Java code I'm then checking whether I have data for datatable or not. If
I have the data, I'm importing the libraries:

 // import datatables and tabletools JS libraries
javaScriptSupport.importJavaScriptLibrary(jqueryUi);
javaScriptSupport.importJavaScriptLibrary(tableTools);
javaScriptSupport.importJavaScriptLibrary(dataTablesEditorMin);
javaScriptSupport.importJavaScriptLibrary(dataTablesEditorCommons);

It works perfectly :), thank you :).

Regards,
Lidija


On Wed, Oct 23, 2013 at 1:55 PM, Thiago H de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Wed, 23 Oct 2013 07:14:43 -0200, Steve steves...@gmail.com wrote:

  Hi Lidija,


 Hi, guys!


  I had a similar question myself about conditionally including
 libraries and I believe you can find the answer here:
 http://tapestry.apache.org/**javascript.htmlhttp://tapestry.apache.org/javascript.html

 If you scroll down (or ctrl +f) to The importJavaScriptLibrary
 method - I think this may help you. It looks like the approach you
 are using is also documented under Approach 1: @Import.


 @Import will always do the import. I you use 
 JavaScriptSupport.**importJavaScriptLibrary(),
 you can do it dynamically. In addition, your problem may be solved by
 adding a test in the JavaScript code to check whether the table is actually
 there before applying the jQuery data table on it.


  Hope this helps, i'm new to Tapestry myself so please take what I say
 with a pinch of salt, but the documentation seems to show how it can
 be done (I believe you would just need an if statement in your page
 class).


 That's correct. :)

 --
 Thiago H. de Paula Figueiredo
 Tapestry, Java and Hibernate consultant and developer
 http://machina.com.br


 --**--**-
 To unsubscribe, e-mail: 
 users-unsubscribe@tapestry.**apache.orgusers-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: Datatables warning when using t:if test....

2013-10-24 Thread Lance Java
Note that @Import can also be placed on render methods (eg setupRender)
instead of annotating at the class level. If used on a render method, the
import will only happen when the component is actually rendered. This might
be cleaner in this case.


Re: Datatables warning when using t:if test....

2013-10-24 Thread lidijaldo .
Will keep that in mind, thanks!

Regards,
Lidija


On Thu, Oct 24, 2013 at 5:46 PM, Lance Java lance.j...@googlemail.comwrote:

 Note that @Import can also be placed on render methods (eg setupRender)
 instead of annotating at the class level. If used on a render method, the
 import will only happen when the component is actually rendered. This might
 be cleaner in this case.



Re: Datatables warning when using t:if test....

2013-10-23 Thread lidijaldo .
I figured out the difference:

when the if condition is met, the datatable isn't displayed.

The HTML source has the following libraries included:
script src=/assets/0.0.1-SNAPSHOT/ctx/js/jquery-ui-1.8.19.custom.min.js
type=text/javascript/script
script src=/assets/0.0.1-SNAPSHOT/ctx/js/TableTools.js
type=text/javascript/script
script src=/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.min.js
type=text/javascript/script
script src=/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.commons.js
type=text/javascript/script

When the if condition is NOT met, the datatable is displayed and ALSO the
tapestry libraries for datatables are included:

script
src=/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/jquery.dataTables.js
type=text/javascript/script
script
src=/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/dataTables.js
type=text/javascript/script

These 2 libraries are not included when the if condition is met and that's
why the javascript error occurs.

Is there a way to conditionally import the below javascript libraries?

@Import(stylesheet = {
context:layout/datatables/css/jquery.dataTables.css,
context:layout/datatables/css/dataTables.editor.css,
context:layout/tabletools/css/TableTools.css
},
library = {
context:js/jquery-ui-1.8.19.custom.min.js,
context:js/TableTools.js,
context:js/dataTables.editor.min.js,
context:js/dataTables.editor.commons.js
})

I don't want these libraries to be included when I'm not displaying the
datatable.
The second option is to include Tapestry's jquery.dataTables.js and
dataTables.js even in case when I'm not displaying the datatable.

How can this be easily achieved?

Regards,
Lidija


On Wed, Oct 23, 2013 at 7:29 AM, lidijaldo . lidija@gmail.com wrote:

 Hi,

 I stumbled upon the next warning a couple of times already and I still
 don't understand why I'm getting it. In our tapestry application we're
 using jquery datatables and it works ok. But in some cases the application
 starts giving me a javascript alert: *Warning: TableTools 2 requires
 DataTables 1.9.0 or newer - www.datatables.net/download*.

 In the Javascript console I see the following errors:

 TypeError: f.fn.DataTable is undefined

 ...ools:{});TableTools._aInstances.push(a);return 
 a.dom.container},cFeature:T,sFe...

 TableTools.js (line 76)
 TypeError: j is undefined

 ...(){},open:function(){},close:function(){}};f.models.field={className:,name:nul...

 dataTamin.js (line 13)
 TypeError: $.fn.dataTable is undefined

 editor = new $.fn.dataTable.Editor(options);// editor



 This is my tml file:

 html t:type=layout
   title=Modules
   xmlns:t=http://tapestry.apache.org/schema/tapestry_5_3.xsd;
   xmlns:h=tapestry-library:jquery
   xmlns:p=tapestry:parameter

 div class=container
 br style=clear: both; /

 t:form t:id=moduleForm id=moduleForm class=TTWForm
 ui-sortable t:type=form 
 Choose module:
 select t:type=select
 t:id=selectModule
 t:model=moduleSelectModel
 encoder=moduleSelectEncoder
 t:value=module
 /
 input type=submit value=Submit/
 /t:form

 div class=clear/div
 /div

 t:if test=isModuleSelected
 table t:type=jquery/datatable t:id=najdiEdiDataTable
 t:source=datasource
t:row=dataTableRow t:rowIndex=index
 t:model=sourcemodel
t:rowsPerPage=10 t:options=dataTableOptions
 t:mode=true /
 /t:if

 /html


 ... Notice the section t:if test=...
 I'm trying not to display the datatable if there is no option selected via
 the dropdown menu.
 If I remove the t:if, there is no warning and the datatable is always
 displayed. If there is no option selected in the dropdown menu, it is
 empty, which is fine.

 So why the javascript error? What does the t:if have to do with it?

 Thanks in advance,
 Lidija




Re: Datatables warning when using t:if test....

2013-10-23 Thread Steve
Hi Lidija,

I had a similar question myself about conditionally including
libraries and I believe you can find the answer here:
http://tapestry.apache.org/javascript.html

If you scroll down (or ctrl +f) to The importJavaScriptLibrary
method - I think this may help you. It looks like the approach you
are using is also documented under Approach 1: @Import.

Hope this helps, i'm new to Tapestry myself so please take what I say
with a pinch of salt, but the documentation seems to show how it can
be done (I believe you would just need an if statement in your page
class).

Thanks,
Steve

On 23 October 2013 07:24, lidijaldo . lidija@gmail.com wrote:
 I figured out the difference:

 when the if condition is met, the datatable isn't displayed.

 The HTML source has the following libraries included:
 script src=/assets/0.0.1-SNAPSHOT/ctx/js/jquery-ui-1.8.19.custom.min.js
 type=text/javascript/script
 script src=/assets/0.0.1-SNAPSHOT/ctx/js/TableTools.js
 type=text/javascript/script
 script src=/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.min.js
 type=text/javascript/script
 script src=/assets/0.0.1-SNAPSHOT/ctx/js/dataTables.editor.commons.js
 type=text/javascript/script

 When the if condition is NOT met, the datatable is displayed and ALSO the
 tapestry libraries for datatables are included:

 script
 src=/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/jquery.dataTables.js
 type=text/javascript/script
 script
 src=/assets/0.0.1-SNAPSHOT/jquery/assets/components/datatables/dataTables.js
 type=text/javascript/script

 These 2 libraries are not included when the if condition is met and that's
 why the javascript error occurs.

 Is there a way to conditionally import the below javascript libraries?

 @Import(stylesheet = {
 context:layout/datatables/css/jquery.dataTables.css,
 context:layout/datatables/css/dataTables.editor.css,
 context:layout/tabletools/css/TableTools.css
 },
 library = {
 context:js/jquery-ui-1.8.19.custom.min.js,
 context:js/TableTools.js,
 context:js/dataTables.editor.min.js,
 context:js/dataTables.editor.commons.js
 })

 I don't want these libraries to be included when I'm not displaying the
 datatable.
 The second option is to include Tapestry's jquery.dataTables.js and
 dataTables.js even in case when I'm not displaying the datatable.

 How can this be easily achieved?

 Regards,
 Lidija


 On Wed, Oct 23, 2013 at 7:29 AM, lidijaldo . lidija@gmail.com wrote:

 Hi,

 I stumbled upon the next warning a couple of times already and I still
 don't understand why I'm getting it. In our tapestry application we're
 using jquery datatables and it works ok. But in some cases the application
 starts giving me a javascript alert: *Warning: TableTools 2 requires
 DataTables 1.9.0 or newer - www.datatables.net/download*.

 In the Javascript console I see the following errors:

 TypeError: f.fn.DataTable is undefined

 ...ools:{});TableTools._aInstances.push(a);return 
 a.dom.container},cFeature:T,sFe...

 TableTools.js (line 76)
 TypeError: j is undefined

 ...(){},open:function(){},close:function(){}};f.models.field={className:,name:nul...

 dataTamin.js (line 13)
 TypeError: $.fn.dataTable is undefined

 editor = new $.fn.dataTable.Editor(options);// editor



 This is my tml file:

 html t:type=layout
   title=Modules
   xmlns:t=http://tapestry.apache.org/schema/tapestry_5_3.xsd;
   xmlns:h=tapestry-library:jquery
   xmlns:p=tapestry:parameter

 div class=container
 br style=clear: both; /

 t:form t:id=moduleForm id=moduleForm class=TTWForm
 ui-sortable t:type=form 
 Choose module:
 select t:type=select
 t:id=selectModule
 t:model=moduleSelectModel
 encoder=moduleSelectEncoder
 t:value=module
 /
 input type=submit value=Submit/
 /t:form

 div class=clear/div
 /div

 t:if test=isModuleSelected
 table t:type=jquery/datatable t:id=najdiEdiDataTable
 t:source=datasource
t:row=dataTableRow t:rowIndex=index
 t:model=sourcemodel
t:rowsPerPage=10 t:options=dataTableOptions
 t:mode=true /
 /t:if

 /html


 ... Notice the section t:if test=...
 I'm trying not to display the datatable if there is no option selected via
 the dropdown menu.
 If I remove the t:if, there is no warning and the datatable is always
 displayed. If there is no option selected in the dropdown menu, it is
 empty, which is fine.

 So why the javascript error? What does the t:if have to do with it?

 Thanks in advance,
 Lidija



-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Datatables warning when using t:if test....

2013-10-23 Thread Thiago H de Paula Figueiredo

On Wed, 23 Oct 2013 07:14:43 -0200, Steve steves...@gmail.com wrote:


Hi Lidija,


Hi, guys!


I had a similar question myself about conditionally including
libraries and I believe you can find the answer here:
http://tapestry.apache.org/javascript.html

If you scroll down (or ctrl +f) to The importJavaScriptLibrary
method - I think this may help you. It looks like the approach you
are using is also documented under Approach 1: @Import.


@Import will always do the import. I you use  
JavaScriptSupport.importJavaScriptLibrary(), you can do it dynamically. In  
addition, your problem may be solved by adding a test in the JavaScript  
code to check whether the table is actually there before applying the  
jQuery data table on it.



Hope this helps, i'm new to Tapestry myself so please take what I say
with a pinch of salt, but the documentation seems to show how it can
be done (I believe you would just need an if statement in your page
class).


That's correct. :)

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Datatables warning when using t:if test....

2013-10-22 Thread lidijaldo .
Hi,

I stumbled upon the next warning a couple of times already and I still
don't understand why I'm getting it. In our tapestry application we're
using jquery datatables and it works ok. But in some cases the application
starts giving me a javascript alert: *Warning: TableTools 2 requires
DataTables 1.9.0 or newer - www.datatables.net/download*.

In the Javascript console I see the following errors:

TypeError: f.fn.DataTable is undefined

...ools:{});TableTools._aInstances.push(a);return
a.dom.container},cFeature:T,sFe...

TableTools.js (line 76)
TypeError: j is undefined

...(){},open:function(){},close:function(){}};f.models.field={className:,name:nul...

dataTamin.js (line 13)
TypeError: $.fn.dataTable is undefined

editor = new $.fn.dataTable.Editor(options);// editor



This is my tml file:

html t:type=layout
  title=Modules
  xmlns:t=http://tapestry.apache.org/schema/tapestry_5_3.xsd;
  xmlns:h=tapestry-library:jquery
  xmlns:p=tapestry:parameter

div class=container
br style=clear: both; /

t:form t:id=moduleForm id=moduleForm class=TTWForm
ui-sortable t:type=form 
Choose module:
select t:type=select
t:id=selectModule
t:model=moduleSelectModel
encoder=moduleSelectEncoder
t:value=module
/
input type=submit value=Submit/
/t:form

div class=clear/div
/div

t:if test=isModuleSelected
table t:type=jquery/datatable t:id=najdiEdiDataTable
t:source=datasource
   t:row=dataTableRow t:rowIndex=index
t:model=sourcemodel
   t:rowsPerPage=10 t:options=dataTableOptions
t:mode=true /
/t:if

/html


... Notice the section t:if test=...
I'm trying not to display the datatable if there is no option selected via
the dropdown menu.
If I remove the t:if, there is no warning and the datatable is always
displayed. If there is no option selected in the dropdown menu, it is
empty, which is fine.

So why the javascript error? What does the t:if have to do with it?

Thanks in advance,
Lidija


How to test using JUnit4 when there is @InjectComponent

2013-07-15 Thread newbie newbie
Hi,
**

I am testing using Junit4 with eclipse. I want to test the function
expandAll

public void expandAll(TreeExpansionModelTreeData expansionModel)
{
ListTreeNodeTreeData roots = getTreeModel().getRootNodes();
for (TreeNodeTreeData root : roots)
{
expandAllNode(root, expansionModel);
}
}

private void expandAllNode(TreeNodeTreeData node,
TreeExpansionModelTreeData expansionModel)
{
   if (node.getHasChildren())
  {
  expansionModel.markExpanded(node);
  for (TreeNode child : node.getChildren())
 {
 expandAllNode(child, expansionModel); // this is a recursive
call
  }
   }
}



The problem I am having is the expansionModel. In my program(not test), I
pass in the expansionModel using tree. Here is the code fragment from java.

@InjectComponent
private Tree tree;

public void onExpandAll()
{
 expansionModel = tree.getExpansionModel();
 treeFunction.expandAll(expansionModel);

 ajaxResponseRenderer.addRender(treeZone);

}

I have tried in my test using

tree = new Tree();
expansionModel = tree.getExpansionModel();
testing.expandAll(expansionModel);

but the expansionModel I get is null. How do I go about testing with
@InjectComponent tree? Any help would be appreciated. Thanks.


Re: Is it possible somehow to get tapestry5 service from within integration test?

2013-04-17 Thread Dmitry Gusev
https://issues.apache.org/jira/browse/TAP5-2107


On Tue, Apr 16, 2013 at 8:17 PM, Dmitry Gusev dmitry.gu...@gmail.comwrote:

 Here's a piece of SeleniumTestCase that does what I wanted:

 private ServletContainerRunner servletContainerRunner;



 public Registry getRegistry()

 {

 if (servletContainerRunner instanceof Jetty7Runner)

 {

 Server server = ((Jetty7Runner) servletContainerRunner
 ).getServer();



 WebAppContext context = (WebAppContext) server.getHandler();



 ServletContext servletContext = context.getServletContext();



 Object registry = servletContext.getAttribute(TapestryFilter.
 REGISTRY_CONTEXT_NAME);



 return (Registry) registry;

 }



 if (servletContainerRunner instanceof Tomcat6Runner)

 {

 try

 {

 Field field = Tomcat6Runner.class.getDeclaredField(
 tomcatServer);

 field.setAccessible(true);



 Embedded server = (Embedded) field.get(
 servletContainerRunner);

 Engine engine = (Engine) server.getContainer();

 Host host = (Host) engine.findChild(localhost);

 Context context = (Context) host.findChildren()[0];

 ServletContext servletContext =
 context.getServletContext();



 Object registry =
 servletContext.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);



 return (Registry) registry;

 }

 catch (Exception e)

 {

 throw new RuntimeException(e);

 }

 }



 throw new RuntimeException(Unsupported runner  +
 servletContainerRunner);

 }



 protected Runnable launchWebServer(String container, String
 webAppFolder, String contextPath, int port, int sslPort)

 throws Exception

 {

 final ServletContainerRunner runner;

 if (TOMCAT_6.equals(container))

 runner = new Tomcat6Runner(webAppFolder, contextPath, port,
 sslPort);

 else if (JETTY_7.equals(container))

 runner = new Jetty7Runner(webAppFolder, contextPath, port,
 sslPort);

 else

 throw new RuntimeException(Unknown servlet container:  +
 container);


 this.servletContainerRunner = runner;

 Method getRegistry() could be easily implemented by ServletContainerRunner
 interface without any reflection.
 It would be nice to have it in there.
 Should I file a JIRA for this or somebody of committers will integrate
 this?

 On Tue, Apr 16, 2013 at 7:01 PM, Dmitry Gusev dmitry.gu...@gmail.comwrote:

 Michael,

 I already use RegistryBuilder in some of my tests.
 It allows me to test services, but in this case I'm working with my
 application using Java API.

 With SeleniumTestCase I can trigger my application handlers using HTTP
 requests via Selenium.
 In this case my application already running and it has constructed
 Registry instance and I'd like to get that instance somehow.

 I'm looking at implementation of SeleniumTestCase and see that there's
 not API for obtaining that Registry instance directly.
 Though, I can see that instance in debugger in my IDE, I think I'll use
 reflection to get it.

 On Tue, Apr 16, 2013 at 6:50 PM, Michael Prescott 
 michael.r.presc...@gmail.com wrote:

 You can use the RegistryBuilder to instantiate your tapestry services via
 Tapestry IOC, I'm finding that very handy.  That's described here:

 http://tapestry.apache.org/starting-the-ioc-registry.html


 On 16 April 2013 10:38, Dmitry Gusev dmitry.gu...@gmail.com wrote:

  I'm writing integration tests (using SeleniumTestCase) and want to make
  assertions against database state.
 
  I was thinking about getting one of my DAO services (or JPA
  EntityManager/Source) and use it to run queries.
 
  Is it possible somehow? Or should I just write another client code that
  would access database from integration tests?
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com




 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Is it possible somehow to get tapestry5 service from within integration test?

2013-04-16 Thread Dmitry Gusev
I'm writing integration tests (using SeleniumTestCase) and want to make
assertions against database state.

I was thinking about getting one of my DAO services (or JPA
EntityManager/Source) and use it to run queries.

Is it possible somehow? Or should I just write another client code that
would access database from integration tests?

-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Is it possible somehow to get tapestry5 service from within integration test?

2013-04-16 Thread Michael Prescott
You can use the RegistryBuilder to instantiate your tapestry services via
Tapestry IOC, I'm finding that very handy.  That's described here:

http://tapestry.apache.org/starting-the-ioc-registry.html


On 16 April 2013 10:38, Dmitry Gusev dmitry.gu...@gmail.com wrote:

 I'm writing integration tests (using SeleniumTestCase) and want to make
 assertions against database state.

 I was thinking about getting one of my DAO services (or JPA
 EntityManager/Source) and use it to run queries.

 Is it possible somehow? Or should I just write another client code that
 would access database from integration tests?

 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com



Re: Is it possible somehow to get tapestry5 service from within integration test?

2013-04-16 Thread Dmitry Gusev
Michael,

I already use RegistryBuilder in some of my tests.
It allows me to test services, but in this case I'm working with my
application using Java API.

With SeleniumTestCase I can trigger my application handlers using HTTP
requests via Selenium.
In this case my application already running and it has constructed Registry
instance and I'd like to get that instance somehow.

I'm looking at implementation of SeleniumTestCase and see that there's not
API for obtaining that Registry instance directly.
Though, I can see that instance in debugger in my IDE, I think I'll use
reflection to get it.

On Tue, Apr 16, 2013 at 6:50 PM, Michael Prescott 
michael.r.presc...@gmail.com wrote:

 You can use the RegistryBuilder to instantiate your tapestry services via
 Tapestry IOC, I'm finding that very handy.  That's described here:

 http://tapestry.apache.org/starting-the-ioc-registry.html


 On 16 April 2013 10:38, Dmitry Gusev dmitry.gu...@gmail.com wrote:

  I'm writing integration tests (using SeleniumTestCase) and want to make
  assertions against database state.
 
  I was thinking about getting one of my DAO services (or JPA
  EntityManager/Source) and use it to run queries.
 
  Is it possible somehow? Or should I just write another client code that
  would access database from integration tests?
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Is it possible somehow to get tapestry5 service from within integration test?

2013-04-16 Thread Dmitry Gusev
Here's a piece of SeleniumTestCase that does what I wanted:

private ServletContainerRunner servletContainerRunner;



public Registry getRegistry()

{

if (servletContainerRunner instanceof Jetty7Runner)

{

Server server = ((Jetty7Runner) servletContainerRunner
).getServer();



WebAppContext context = (WebAppContext) server.getHandler();



ServletContext servletContext = context.getServletContext();



Object registry = servletContext.getAttribute(TapestryFilter.
REGISTRY_CONTEXT_NAME);



return (Registry) registry;

}



if (servletContainerRunner instanceof Tomcat6Runner)

{

try

{

Field field = Tomcat6Runner.class.getDeclaredField(
tomcatServer);

field.setAccessible(true);



Embedded server = (Embedded) field.get(
servletContainerRunner);

Engine engine = (Engine) server.getContainer();

Host host = (Host) engine.findChild(localhost);

Context context = (Context) host.findChildren()[0];

ServletContext servletContext = context.getServletContext();



Object registry =
servletContext.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);



return (Registry) registry;

}

catch (Exception e)

{

throw new RuntimeException(e);

}

}



throw new RuntimeException(Unsupported runner  +
servletContainerRunner);

}



protected Runnable launchWebServer(String container, String
webAppFolder, String contextPath, int port, int sslPort)

throws Exception

{

final ServletContainerRunner runner;

if (TOMCAT_6.equals(container))

runner = new Tomcat6Runner(webAppFolder, contextPath, port,
sslPort);

else if (JETTY_7.equals(container))

runner = new Jetty7Runner(webAppFolder, contextPath, port,
sslPort);

else

throw new RuntimeException(Unknown servlet container:  +
container);


this.servletContainerRunner = runner;

Method getRegistry() could be easily implemented by ServletContainerRunner
interface without any reflection.
It would be nice to have it in there.
Should I file a JIRA for this or somebody of committers will integrate this?

On Tue, Apr 16, 2013 at 7:01 PM, Dmitry Gusev dmitry.gu...@gmail.comwrote:

 Michael,

 I already use RegistryBuilder in some of my tests.
 It allows me to test services, but in this case I'm working with my
 application using Java API.

 With SeleniumTestCase I can trigger my application handlers using HTTP
 requests via Selenium.
 In this case my application already running and it has constructed
 Registry instance and I'd like to get that instance somehow.

 I'm looking at implementation of SeleniumTestCase and see that there's not
 API for obtaining that Registry instance directly.
 Though, I can see that instance in debugger in my IDE, I think I'll use
 reflection to get it.

 On Tue, Apr 16, 2013 at 6:50 PM, Michael Prescott 
 michael.r.presc...@gmail.com wrote:

 You can use the RegistryBuilder to instantiate your tapestry services via
 Tapestry IOC, I'm finding that very handy.  That's described here:

 http://tapestry.apache.org/starting-the-ioc-registry.html


 On 16 April 2013 10:38, Dmitry Gusev dmitry.gu...@gmail.com wrote:

  I'm writing integration tests (using SeleniumTestCase) and want to make
  assertions against database state.
 
  I was thinking about getting one of my DAO services (or JPA
  EntityManager/Source) and use it to run queries.
 
  Is it possible somehow? Or should I just write another client code that
  would access database from integration tests?
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


tapestry-test question

2013-02-19 Thread Rural Hunter

Hi,

Does the |SeleniumTestCase support to test jsp? I just created a testng 
suite and when I tried to test a jsp, the test class just got the jsp 
source not the generated/compiled html file. I used tomcat6 as the test 
servlet container because we use tomcat in both dev/prod environment and 
jetty doesn't read the JNDI info in META-INFO/context.xml.

|

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: tapestry-test question

2013-02-19 Thread Taha Siddiqi
Hi

You should be able to use SeleniumTestCase for testing jsp. If it is not 
working I would look into the jetty configuration for jsp e.g. 
http://wiki.eclipse.org/Jetty/Howto/Configure_JSP

For configuring JNDI in jetty, you have to use the jetty.xml under the 
/WEB-INF/web directory.

http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource

regards
Taha


On Feb 19, 2013, at 9:43 PM, Rural Hunter wrote:

 Hi,
 
 Does the |SeleniumTestCase support to test jsp? I just created a testng suite 
 and when I tried to test a jsp, the test class just got the jsp source not 
 the generated/compiled html file. I used tomcat6 as the test servlet 
 container because we use tomcat in both dev/prod environment and jetty 
 doesn't read the JNDI info in META-INFO/context.xml.
 |
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 



Re: tapestry-test question

2013-02-19 Thread Rural Hunter

Thanks Taha.

I was using SeleniumTestCase. After investigation, I found the 
Tomcat6Runner doesn't support jsp. it doesn't include the wrapper for 
jsp servlet nor the mapping for *.jsp. I created a new runner based on 
it and now it's working.


于 2013/2/20 0:36, Taha Siddiqi 写道:

Hi

You should be able to use SeleniumTestCase for testing jsp. If it is not 
working I would look into the jetty configuration for jsp e.g. 
http://wiki.eclipse.org/Jetty/Howto/Configure_JSP

For configuring JNDI in jetty, you have to use the jetty.xml under the 
/WEB-INF/web directory.

http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource

regards
Taha


On Feb 19, 2013, at 9:43 PM, Rural Hunter wrote:


Hi,

Does the |SeleniumTestCase support to test jsp? I just created a testng suite 
and when I tried to test a jsp, the test class just got the jsp source not the 
generated/compiled html file. I used tomcat6 as the test servlet container 
because we use tomcat in both dev/prod environment and jetty doesn't read the 
JNDI info in META-INFO/context.xml.
|

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org






-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How to get code coverage of Integration Test ?

2013-01-29 Thread Stephan Windmüller
On 28.01.2013 15:58, Julien Smadja wrote:

 I have a coverage percent for classes in packages like domain, but nothing
 in pages or components.
 
 Do you have a solution for this ? Is this a problem with javassist ?

IIRC we had the same problem using EMMA[0].

What did work was the code coverage integrated in IntelliJ IDEA[1]. We
started our application server from within the IDE and were able to
measure the code coverage of Tapestry pages.

HTH
 Stephan

[0] http://emma.sourceforge.net/
[1] http://www.jetbrains.com/idea/webhelp/code-coverage-2.html



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: How to get code coverage of Integration Test ?

2013-01-29 Thread Julien Smadja
Thank you, I'll test your solution with Idea 12, and I'll tell you if it
works too.


2013/1/29 Stephan Windmüller stephan.windmuel...@tu-dortmund.de

 On 28.01.2013 15:58, Julien Smadja wrote:

  I have a coverage percent for classes in packages like domain, but
 nothing
  in pages or components.
 
  Do you have a solution for this ? Is this a problem with javassist ?

 IIRC we had the same problem using EMMA[0].

 What did work was the code coverage integrated in IntelliJ IDEA[1]. We
 started our application server from within the IDE and were able to
 measure the code coverage of Tapestry pages.

 HTH
  Stephan

 [0] http://emma.sourceforge.net/
 [1] http://www.jetbrains.com/idea/webhelp/code-coverage-2.html




-- 

*Julien Smadja*

 Email : jsma...@xebia.fr

Mobile : +33(0)6 59 11 72 31

http://www.xebia.fr

http://blog.xebia.fr

*Siège Social*

La Défense Colisée

10 / 12 Avenue de l'arche

Faubourg de l'Arche

92419 Courbevoie Cedex


Re: How to get code coverage of Integration Test ?

2013-01-29 Thread Julien Smadja
Yes, it works.

I had to use Tomcat server instead of mvn tomcat:run command in Intellij
Idea.

Unfortunately, I think I won't be able to automatize this task.

Thank you for your answer.


Re: How to get code coverage of Integration Test ?

2013-01-29 Thread Stephan Windmüller
On 29.01.2013 11:29, Julien Smadja wrote:

 Unfortunately, I think I won't be able to automatize this task.

You could try the integration server from Jetbrains, Teamcity, but I do
not know if it is able to perform the same instrumentation as IDEA.

http://www.jetbrains.com/teamcity/

- Stephan



smime.p7s
Description: S/MIME Kryptografische Unterschrift


Re: How to get code coverage of Integration Test ?

2013-01-29 Thread Lenny Primak
Have you tried running in production mode?  That might work better. 

On Jan 29, 2013, at 3:05 AM, Stephan Windmüller 
stephan.windmuel...@tu-dortmund.de wrote:

 On 28.01.2013 15:58, Julien Smadja wrote:
 
 I have a coverage percent for classes in packages like domain, but nothing
 in pages or components.
 
 Do you have a solution for this ? Is this a problem with javassist ?
 
 IIRC we had the same problem using EMMA[0].
 
 What did work was the code coverage integrated in IntelliJ IDEA[1]. We
 started our application server from within the IDE and were able to
 measure the code coverage of Tapestry pages.
 
 HTH
 Stephan
 
 [0] http://emma.sourceforge.net/
 [1] http://www.jetbrains.com/idea/webhelp/code-coverage-2.html
 

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



How to get code coverage of Integration Test ?

2013-01-28 Thread Julien Smadja
Hello,

I'm working on a  40K lines of code project.

We're using :

tapestry-release-version5.3.3/tapestry-release-version

tapestry-security-version0.4.4/tapestry-security-version

got5-release-version3.3.3/got5-release-version

jacoco.version0.6.1.201212231917/jacoco.version

I'm launching my application with *mvn clean tomcat:run* with agent : *
-javaagent:/Users/juliensmadja/.m2/repository/org/jacoco/org.jacoco.agent/0.6.1.201212231917/jacocoagent.jar=destfile=/tmp/jacoco.file.path
*

Then, I launch my selenium tests.

After the execution,  I start my *Sonar 3.4.1* and execute goal *
sonar:sonar *on my project*.*

*mvn sonar:sonar -Dsonar.jacoco.itReportPath=/tmp/jacoco.dump -fn*

And my problem is : *tapestry's components, pages, forms don't seem to be
instrumented* because there is no coverage when watching in Sonar Report.

I have a coverage percent for classes in packages like domain, but nothing
in pages or components.

Do you have a solution for this ? Is this a problem with javassist ?

Thank you

-- 

*Julien Smadja*

 Email : jsma...@xebia.fr

Mobile : +33(0)6 59 11 72 31

http://www.xebia.fr

http://blog.xebia.fr

*Siège Social*

La Défense Colisée

10 / 12 Avenue de l'arche

Faubourg de l'Arche

92419 Courbevoie Cedex


Re: How to get code coverage of Integration Test ?

2013-01-28 Thread Steve Eynon
T5 instruments pages and components itself and uses it's own class
loader to reload them, so it's very unlikely Sonar is able to hook
that. (Not that I know anything of Sonar.)

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



JMeter Load Test example

2013-01-18 Thread sthomps
Thought I would give back a little to the community for all your help.

As JMeter is not the easiest tool to use, here's a very simple load-test for
testing an Ajax submit on a form. 

load-test.jmx
http://tapestry.1045711.n5.nabble.com/file/n5719384/load-test.jmx   





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/JMeter-Load-Test-example-tp5719384.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Unable to load messages in UTF-8 encoding in test class/ in different class than messages belong to

2012-11-08 Thread Balázs Palcsó
Hi,

After a bit more investigation. I would say that
private final Messages messages = MessagesImpl.forClass(Registration.class);
would be the proper solution to load messages of my Registration page if
MessagesImpl.forClass(Class) used UTF-8 encoding instead of the default
ISO-8859-1 (latin1) when loading properties files.
In pages and components my UTF-8 encoded properties files work correctly as
documented at http://tapestry.apache.org/localization.html

The reason I want to access the messages of a page to be able to assert
that the correct messages have been printed on the page. But I don't want
duplicate the message by hard-coding them in my tests.

I believe MessagesImpl.forClass(Class) should also load the properties file
with UTF-8 encoding. and could be moved from internal package to become
part of the public API.
What do you think? Shall I open a task in JIRA?

Thanks and regards,
Balazs


On 8 November 2012 08:37, Balázs Palcsó palcso.bal...@gmail.com wrote:

 Hi All,

 I am new to Tapestry. I am creating a test with Tapestry Testify and
 XPath. Everything works fine except that in my test class I am not able to
 load Messages from properties file stored in UTF-8 encoding.

 In my RegistrationTest class I have tried the followings:
 *#1*
 private final Messages messages =
 MessagesImpl.forClass(Registration.class); // This loads the messages
 successfully, but does not seem to read the file with UTF-8 encoding

 *#2*
 @Inject
   private Messages messages; //Here I don't know how to specify that I
 need the Messages of Registration.class

 messages.get(PasswordsDontMatch) returns: (java.lang.String) [[missing
 key: PasswordsDontMatch]]

 *#3*
 I wanted to try MessagesSourceImpl, but it requires quite complex
 parametrization.

 Any hint is appreciated.

 Thanks and regards,
 Balazs Palcso



Unable to load messages in UTF-8 encoding in test class/ in different class than messages belong to

2012-11-07 Thread Balázs Palcsó
Hi All,

I am new to Tapestry. I am creating a test with Tapestry Testify and XPath.
Everything works fine except that in my test class I am not able to load
Messages from properties file stored in UTF-8 encoding.

In my RegistrationTest class I have tried the followings:
*#1*
private final Messages messages =
MessagesImpl.forClass(Registration.class); // This loads the messages
successfully, but does not seem to read the file with UTF-8 encoding

*#2*
@Inject
  private Messages messages; //Here I don't know how to specify that I need
the Messages of Registration.class

messages.get(PasswordsDontMatch) returns: (java.lang.String) [[missing
key: PasswordsDontMatch]]

*#3*
I wanted to try MessagesSourceImpl, but it requires quite complex
parametrization.

Any hint is appreciated.

Thanks and regards,
Balazs Palcso


Re: Plastic: Test that 2 object references are equal

2012-09-14 Thread Howard Lewis Ship
Currently, there isn't a way to perform a == using the bytecode API.

On Tue, Sep 4, 2012 at 9:03 AM, Josh Canfield joshcanfi...@gmail.comwrote:

 Perhaps I don't understand what you mean by using plastic. Plastic doesn't
 change how equality works. == is reference compare, use .equals if they are
 objects. Are you trying to inject .equals into a transformed object?


 On Mon, Sep 3, 2012 at 1:39 AM, Thim Anneessens t.anneess...@ictjob.bewrote:

  Hi Josh,

 I am trying to generate byte-code that will test if 2 object references
 are equal using Plastic.

 Thanks.
 Thim.


 On 08/25/2012 05:13 PM, Josh Canfield wrote:

 Hi Thim.

 Your question doesn't make any sense. What are you trying to do at a higher
 level?

 Josh
 On Aug 24, 2012 2:03 PM, Thim Anneessens thimw...@gmail.com 
 thimw...@gmail.com wrote:


  Hello,

 I am wondering how to achieve the following java code in plastic:

 Object a,b;
 if(a==b)
   // Do something
 else
   // Do something else

 Does anybody know how?

 Best regards,
 Thim.

 --**--**-
 To unsubscribe, e-mail: 
 users-unsubscribe@tapestry.**apache.orgusers-unsubscr...@tapestry.apache.org
  users-unsubscr...@tapestry.apache.org



 For additional commands, e-mail: users-h...@tapestry.apache.org



 --
  * Thim Anneessens
 IT Department *

 [image: ictjob group]

   ictjob.be http://www.ictjob.be
 Tel: +32 2 725 73 00
 Ikaroslaan, 2
 B-1930 Zaventem  ictjob.lu http://www.ictjob.lu
 Tel: +352 621 364 792
 12, rue Eugène Ruppert
 L-2453 Luxembourg  jobtic.fr http://www.jobtic.fr
 Tel: +33 9 81 25 19 66
 19 rue Martel
 75010 Paris  ticjob.es http://www.ticjob.es
 Tel: +34 911 25 43 11
 Calle Santo Tomé 4, 5B
 28004 Madrid  ictjob.de http://www.ictjob.de
 Tel: +49 711 91 41 07 32
 Humboldtstr. 32
 70771 Leinfelden-Echterdingen





-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Plastic: Test that 2 object references are equal

2012-09-04 Thread Josh Canfield
Perhaps I don't understand what you mean by using plastic. Plastic doesn't
change how equality works. == is reference compare, use .equals if they are
objects. Are you trying to inject .equals into a transformed object?

On Mon, Sep 3, 2012 at 1:39 AM, Thim Anneessens t.anneess...@ictjob.bewrote:

  Hi Josh,

 I am trying to generate byte-code that will test if 2 object references
 are equal using Plastic.

 Thanks.
 Thim.


 On 08/25/2012 05:13 PM, Josh Canfield wrote:

 Hi Thim.

 Your question doesn't make any sense. What are you trying to do at a higher
 level?

 Josh
 On Aug 24, 2012 2:03 PM, Thim Anneessens thimw...@gmail.com 
 thimw...@gmail.com wrote:


  Hello,

 I am wondering how to achieve the following java code in plastic:

 Object a,b;
 if(a==b)
   // Do something
 else
   // Do something else

 Does anybody know how?

 Best regards,
 Thim.

 --**--**-
 To unsubscribe, e-mail: 
 users-unsubscribe@tapestry.**apache.orgusers-unsubscr...@tapestry.apache.org
  users-unsubscr...@tapestry.apache.org

 For additional commands, e-mail: users-h...@tapestry.apache.org



 --
  * Thim Anneessens
 IT Department *

 [image: ictjob group]

   ictjob.be http://www.ictjob.be
 Tel: +32 2 725 73 00
 Ikaroslaan, 2
 B-1930 Zaventem  ictjob.lu http://www.ictjob.lu
 Tel: +352 621 364 792
 12, rue Eugène Ruppert
 L-2453 Luxembourg  jobtic.fr http://www.jobtic.fr
 Tel: +33 9 81 25 19 66
 19 rue Martel
 75010 Paris  ticjob.es http://www.ticjob.es
 Tel: +34 911 25 43 11
 Calle Santo Tomé 4, 5B
 28004 Madrid  ictjob.de http://www.ictjob.de
 Tel: +49 711 91 41 07 32
 Humboldtstr. 32
 70771 Leinfelden-Echterdingen



Re: Plastic: Test that 2 object references are equal

2012-09-03 Thread Thim Anneessens

  
  
Hi Josh,
  
  I am trying to generate byte-code that will test if 2 object
  references are equal using Plastic.
  
  Thanks.
  Thim.
  
  On 08/25/2012 05:13 PM, Josh Canfield wrote:


  Hi Thim.

Your question doesn't make any sense. What are you trying to do at a higher
level?

Josh
On Aug 24, 2012 2:03 PM, "Thim Anneessens" thimw...@gmail.com wrote:


  
Hello,

I am wondering how to achieve the following java code in plastic:

Object a,b;
if(a==b)
  // Do something
else
  // Do something else

Does anybody know how?

Best regards,
Thim.

--**--**-
To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.orgusers-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



  
  




-- 
  
 Thim Anneessens 
  IT Department








  

   ictjob.be 
Tel: +32 2 725 73 00 
Ikaroslaan, 2 
B-1930 Zaventem
  
   ictjob.lu

Tel: +352 621 364 792 
12, rue Eugne Ruppert 
L-2453 Luxembourg
  
   jobtic.fr

Tel: +33 9 81 25 19 66 
19 rue Martel 
75010 Paris
  
   ticjob.es

Tel: +34 911 25 43 11 
Calle Santo Tom 4, 5B 
28004 Madrid
  
   ictjob.de

Tel: +49 711 91 41 07 32 
Humboldtstr. 32 
70771 Leinfelden-Echterdingen
  

  

  

  



Re: Plastic: Test that 2 object references are equal

2012-08-25 Thread Josh Canfield
Hi Thim.

Your question doesn't make any sense. What are you trying to do at a higher
level?

Josh
On Aug 24, 2012 2:03 PM, Thim Anneessens thimw...@gmail.com wrote:

 Hello,

 I am wondering how to achieve the following java code in plastic:

 Object a,b;
 if(a==b)
   // Do something
 else
   // Do something else

 Does anybody know how?

 Best regards,
 Thim.

 --**--**-
 To unsubscribe, e-mail: 
 users-unsubscribe@tapestry.**apache.orgusers-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Plastic: Test that 2 object references are equal

2012-08-24 Thread Thim Anneessens

Hello,

I am wondering how to achieve the following java code in plastic:

Object a,b;
if(a==b)
  // Do something
else
  // Do something else

Does anybody know how?

Best regards,
Thim.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-28 Thread sommeralex
Thank you all for your answers. 

What I now did is just this in one of my pages:

JAVA

@Property   
@Symbol(tapestry.production-mode)
private boolean productionMode;

TML

t:if test=productionMode

productionMode!

/t:if


My FrontendModule

public static void contributeApplicationDefaults(MappedConfigurationString,
String configuration) {

configuration.add(tapestry.production-mode, true);

}

The String productionMode! is never printed. Using Tapestry 5.3.1.





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-28 Thread Taha Siddiqi
With @Symbol you must use @Inject too

@Proeprty
@Inject
@Symbol(SymbolConstants.PRODUCTION_MODE)
private boolean productionMode

BTW you can also use :-

t:if test='symbol:tapestry.production-mode'
   ${symbol:tapestry.production-mode}
/t:if

regards
Taha


On Jul 28, 2012, at 2:19 PM, sommeralex wrote:

 Thank you all for your answers. 
 
 What I now did is just this in one of my pages:
 
 JAVA
 
 @Property 
 @Symbol(tapestry.production-mode)
 private boolean productionMode;
 
 TML
 
 t:if test=productionMode
   
 productionMode!
   
 /t:if
 
 
 My FrontendModule
 
 public static void contributeApplicationDefaults(MappedConfigurationString,
 String configuration) {
 
 configuration.add(tapestry.production-mode, true);
 
 }
 
 The String productionMode! is never printed. Using Tapestry 5.3.1.
 
 
 
 
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-28 Thread sommeralex
thank you very much, it works!

2012/7/28 Taha Hafeez [via Tapestry] 
ml-node+s1045711n5714850...@n5.nabble.com

 With @Symbol you must use @Inject too

 @Proeprty
 @Inject
 @Symbol(SymbolConstants.PRODUCTION_MODE)
 private boolean productionMode

 BTW you can also use :-

 t:if test='symbol:tapestry.production-mode'
${symbol:tapestry.production-mode}
 /t:if

 regards
 Taha


 On Jul 28, 2012, at 2:19 PM, sommeralex wrote:

  Thank you all for your answers.
 
  What I now did is just this in one of my pages:
 
  JAVA
 
  @Property
  @Symbol(tapestry.production-mode)
  private boolean productionMode;
 
  TML
 
  t:if test=productionMode
 
  productionMode!
 
  /t:if
 
 
  My FrontendModule
 
  public static void
 contributeApplicationDefaults(MappedConfigurationString,
  String configuration) {
 
  configuration.add(tapestry.production-mode, true);
 
  }
 
  The String productionMode! is never printed. Using Tapestry 5.3.1.
 
 
 
 
 
  --
  View this message in context:
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html

  Sent from the Tapestry - User mailing list archive at Nabble.com.
 
  -
  To unsubscribe, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=5714850i=0
  For additional commands, e-mail: [hidden 
  email]http://user/SendEmail.jtp?type=nodenode=5714850i=1
 


 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=2
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=3



 --
  If you reply to this email, your message will be added to the discussion
 below:

 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714850.html
  To unsubscribe from Test if production or test mode.., click 
 herehttp://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=5714658code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNDY1OHwxMDUzMzQxMzM4
 .
 NAMLhttp://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714851.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Test if production or test mode..

2012-07-28 Thread Chris Mylonas
Hi - I took the liberty in creating a JIRA for adding this example to the 
symbols page.
Handy example for someone getting into symbolic stuff (excuse my pun-tiness)

https://issues.apache.org/jira/browse/TAP5-1982

Here is the documentation I reckon could do with some more
http://tapestry.apache.org/symbols.html

For the quick and the dirty, it's a good example of injecting a symbol.
Dunno if it's jumpstart-worthy or stuff it into the archetype for more sample 
stuff without overwhelming a noob.

My 2c
Cheers
Chris


On 28/07/2012, at 7:02 PM, sommeralex wrote:

 thank you very much, it works!
 
 2012/7/28 Taha Hafeez [via Tapestry] 
 ml-node+s1045711n5714850...@n5.nabble.com
 
 With @Symbol you must use @Inject too
 
 @Proeprty
 @Inject
 @Symbol(SymbolConstants.PRODUCTION_MODE)
 private boolean productionMode
 
 BTW you can also use :-
 
 t:if test='symbol:tapestry.production-mode'
   ${symbol:tapestry.production-mode}
 /t:if
 
 regards
 Taha
 
 
 On Jul 28, 2012, at 2:19 PM, sommeralex wrote:
 
 Thank you all for your answers.
 
 What I now did is just this in one of my pages:
 
 JAVA
 
 @Property
 @Symbol(tapestry.production-mode)
 private boolean productionMode;
 
 TML
 
 t:if test=productionMode
 
 productionMode!
 
 /t:if
 
 
 My FrontendModule
 
 public static void
 contributeApplicationDefaults(MappedConfigurationString,
 String configuration) {
 
 configuration.add(tapestry.production-mode, true);
 
 }
 
 The String productionMode! is never printed. Using Tapestry 5.3.1.
 
 
 
 
 
 --
 View this message in context:
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714849.html
 
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=0
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=1
 
 
 
 -
 To unsubscribe, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=2
 For additional commands, e-mail: [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=5714850i=3
 
 
 
 --
 If you reply to this email, your message will be added to the discussion
 below:
 
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714850.html
 To unsubscribe from Test if production or test mode.., click 
 herehttp://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=5714658code=YWxleGFuZGVyLnNvbW1lckBnbWFpbC5jb218NTcxNDY1OHwxMDUzMzQxMzM4
 .
 NAMLhttp://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
 
 
 
 
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714851.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.



Re: Test if production or test mode..

2012-07-23 Thread Christian Riedel
…and if you worry about having too many annotations in the constructor, you can 
also omit the @Inject annoation for symbols in recent Tapestry versions (I 
think  5.2). 

@Symbol(SymbolConstants.PRODUCTION_MODE) boolean productionMode


Am 22.07.2012 um 15:34 schrieb Lance Java:

 You can use @Inject, @Value and @Symbol in tapestry services. @Property can
 only be used in pages and components, NOT services.
 
 The following should work in a service:
 
 @Inject @Symbol(tapestry.production-mode)
 private boolean productionMode;
 
 You could also do this:
 
 @Inject @Value(${tapestry.production-mode})
 private boolean productionMode;
 
 I never use private field injection in my services (@Inject) as it makes it
 difficult to test but the option is there if you want it.
 
 
 
 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714674.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org
 


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-23 Thread Thiago H de Paula Figueiredo
On Sat, 21 Jul 2012 12:47:10 -0300, sommeralex  
alexander.som...@gmail.com wrote:



@Value(${tapestry.production-mode})
@Property
private boolean productionMode;


You don't need @Property for injecting stuff. In addition, using @Symbol,  
you don't need to use expansions:


@Inject
@Symbol(SymbolConstants.PRODUCTION_MODE) // or  
@Symbol(tapestry.production-mode), works the same.

private boolean productionMode;


this way sounds much easier than the crpytic form in the constructor:
public class MyService implements MyServiceInterface
{
  public MyService(@Value(${tapestry.production-mode}) boolean
productionMode, ...)
  {
if (productionMode) {

can someone explain me why app properties can not more easiliy requested?


Example of more easily requested way of doing that please. ;)

Do you really wanted an specific annotation just for injecting a single  
symbol?


You could also inject the SymbolSource service and get symbol values from  
it.


--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-22 Thread Lance Java
You can use @Inject, @Value and @Symbol in tapestry services. @Property can
only be used in pages and components, NOT services.

The following should work in a service:

@Inject @Symbol(tapestry.production-mode)
private boolean productionMode;

You could also do this:

@Inject @Value(${tapestry.production-mode})
private boolean productionMode;

I never use private field injection in my services (@Inject) as it makes it
difficult to test but the option is there if you want it.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658p5714674.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Test if production or test mode..

2012-07-21 Thread sommeralex
@Value(${tapestry.production-mode})
@Property
private boolean productionMode;

this way sounds much easier than the crpytic form in the constructor:

public class MyService implements MyServiceInterface
{
  public MyService(@Value(${tapestry.production-mode}) boolean
productionMode, ...)
  {
if (productionMode) {

can someone explain me why app properties can not more easiliy requested?



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Test if production or test mode..

2012-07-21 Thread Howard Lewis Ship
There's very little in Tapestry that could not be readily built in
Tapestry; it's not that what you are doing is impossible, it's just
that there hasn't been a sufficient need to streamline access to this
configuration symbol.

On Sat, Jul 21, 2012 at 8:47 AM, sommeralex alexander.som...@gmail.com wrote:
 @Value(${tapestry.production-mode})
 @Property
 private boolean productionMode;

 this way sounds much easier than the crpytic form in the constructor:

 public class MyService implements MyServiceInterface
 {
   public MyService(@Value(${tapestry.production-mode}) boolean
 productionMode, ...)
   {
 if (productionMode) {

 can someone explain me why app properties can not more easiliy requested?



 --
 View this message in context: 
 http://tapestry.1045711.n5.nabble.com/Test-if-production-or-test-mode-tp5714658.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Robert Lentz
Hi All,

we are currently heavy load testing Tapestry 5.3.4-rc-7 in production
mode with Tomcat 6.0.35, so far it looks pretty good, but sometimes
(mostly) during a test series we
noticed unnecessary repeatly high number of assets requests with a http
status code 200 instead of the expected 304 Not Modified code.
It took me a couple of hours to understand the problem, but I think I
found issue.

Looking at the request headers - the browser will send for example a

If-Modified-Since Thu, 28 Jun 2012 22:32:41 GMT

for a previously received asset with headers like

Last-ModifiedThu, 28 Jun 2012 22:32:41 GMT
ExpiresSun, 26 Jun 2022 22:32:41 GMT

The header If-Modified-Since  which will be parse by Tomcat's
FastHttpDateFormat.parseDate(..) method to a long, when called 
ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
During this parsing any milliseconds are ignored/not available, but
Tapestry's ResourceChangeTrackerImpl service uses milliseconds:

/**
 * Used in production mode as the last modified time of any resource
exposed to the client. Remember that
 * all exposed assets include a URL with a version number, and each
new deployment of the application should change
 * that version number.
 */
private final long fixedLastModifiedTime = System.currentTimeMillis();


   
Attribute fixedLastModifiedTime will be compared against a timestamp
without milliseconds in ResourceStreamerImpl (ifModifiedSince =
lastModified)


if (ifModifiedSince  0)
{
if (ifModifiedSince = lastModified)
{
_response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
}

which mostly doesn't work except in those cases were
System.currentTimeMillis returns a value ending with 000.
Basically what I mean is, that

System.out.println(new Date(1340920037999L));
System.out.println(new Date(1340920037000L));

Thu Jun 28 23:47:17 CEST 2012
Thu Jun 28 23:47:17 CEST 2012

produce the same string date, but the reverse will always be the long
1340920037000L.

For our load tests I have overwritten ResourceChangeTrackerImpl were we
initialize fixedLastModifiedTime like this

private final long fixedLastModifiedTime =
(System.currentTimeMillis()/1000L)*1000;
   
and then everything works as expected.

Is my assumption correct? Any chance to get this fixed for release 5.3.4?

Aloha
 Robert


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Thiago H de Paula Figueiredo

On Thu, 28 Jun 2012 19:38:52 -0300, Robert Lentz rob...@teksolv.de wrote:


Hi All,


Hi!


The header If-Modified-Since  which will be parse by Tomcat's
FastHttpDateFormat.parseDate(..) method to a long, when called
ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
During this parsing any milliseconds are ignored/not available,


Isn't this a Tomcat issue instead of a Tapestry one? Of course, we can fix  
in Tapestry's side and that wouldn't be the first time something like that  
happens. Have you tried Jetty to test whether it happens in it too?


Your fix sounds harmless enough, so I see no reason for it to be  
integrated in Tapestry itself.


And thank you very much for noticing, investigating and provinding a  
solution! :)


--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Robert Lentz
Hi Thiago,

well I don't have jetty available atm, but how would jetty or any other
java date parser parse a string date including seconds but without
milliseconds provided to a long milliseconds value

If-Modified-Since Thu, 28 Jun 2012 22:32:41 GMT


I assume the millis range 000-999 must be ignored and the long will
always ends with 000. Anything else is random - right?

Aloha
 Robert

Thiago H de Paula Figueiredo schrieb:
 On Thu, 28 Jun 2012 19:38:52 -0300, Robert Lentz rob...@teksolv.de
 wrote:

 Hi All,

 Hi!

 The header If-Modified-Since  which will be parse by Tomcat's
 FastHttpDateFormat.parseDate(..) method to a long, when called
 ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
 During this parsing any milliseconds are ignored/not available,

 Isn't this a Tomcat issue instead of a Tapestry one? Of course, we can
 fix in Tapestry's side and that wouldn't be the first time something
 like that happens. Have you tried Jetty to test whether it happens in
 it too?

 Your fix sounds harmless enough, so I see no reason for it to be
 integrated in Tapestry itself.

 And thank you very much for noticing, investigating and provinding a
 solution! :)




-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Howard Lewis Ship
Robert is right on this one; there's code elsewhere to uses the
URLChangeTracker (the core of ResourceChangeTracker) at second (not
millisecond) precision, for this exact scenario ...  I suspect something is
slightly out of wack for it to come back as it has.

On Thu, Jun 28, 2012 at 4:43 PM, Robert Lentz rob...@teksolv.de wrote:

 Hi Thiago,

 well I don't have jetty available atm, but how would jetty or any other
 java date parser parse a string date including seconds but without
 milliseconds provided to a long milliseconds value

 If-Modified-Since Thu, 28 Jun 2012 22:32:41 GMT


 I assume the millis range 000-999 must be ignored and the long will
 always ends with 000. Anything else is random - right?

 Aloha
  Robert

 Thiago H de Paula Figueiredo schrieb:
  On Thu, 28 Jun 2012 19:38:52 -0300, Robert Lentz rob...@teksolv.de
  wrote:
 
  Hi All,
 
  Hi!
 
  The header If-Modified-Since  which will be parse by Tomcat's
  FastHttpDateFormat.parseDate(..) method to a long, when called
  ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
  During this parsing any milliseconds are ignored/not available,
 
  Isn't this a Tomcat issue instead of a Tapestry one? Of course, we can
  fix in Tapestry's side and that wouldn't be the first time something
  like that happens. Have you tried Jetty to test whether it happens in
  it too?
 
  Your fix sounds harmless enough, so I see no reason for it to be
  integrated in Tapestry itself.
 
  And thank you very much for noticing, investigating and provinding a
  solution! :)
 



 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Howard Lewis Ship
Ah, reading back, I see exactly what Robert's getting at: the placeholder
value, used in production, should be limited to one-second precision. This
represents a change in 5.3 to ditch all the code that checks for changes:
literally, the filter responsible is not instantiated in production mode,
and several other services related to propagating events, become no-op
placeholders.

On Thu, Jun 28, 2012 at 6:20 PM, Howard Lewis Ship hls...@gmail.com wrote:

 Robert is right on this one; there's code elsewhere to uses the
 URLChangeTracker (the core of ResourceChangeTracker) at second (not
 millisecond) precision, for this exact scenario ...  I suspect something is
 slightly out of wack for it to come back as it has.


 On Thu, Jun 28, 2012 at 4:43 PM, Robert Lentz rob...@teksolv.de wrote:

 Hi Thiago,

 well I don't have jetty available atm, but how would jetty or any other
 java date parser parse a string date including seconds but without
 milliseconds provided to a long milliseconds value

 If-Modified-Since Thu, 28 Jun 2012 22:32:41 GMT


 I assume the millis range 000-999 must be ignored and the long will
 always ends with 000. Anything else is random - right?

 Aloha
  Robert

 Thiago H de Paula Figueiredo schrieb:
  On Thu, 28 Jun 2012 19:38:52 -0300, Robert Lentz rob...@teksolv.de
  wrote:
 
  Hi All,
 
  Hi!
 
  The header If-Modified-Since  which will be parse by Tomcat's
  FastHttpDateFormat.parseDate(..) method to a long, when called
  ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
  During this parsing any milliseconds are ignored/not available,
 
  Isn't this a Tomcat issue instead of a Tapestry one? Of course, we can
  fix in Tapestry's side and that wouldn't be the first time something
  like that happens. Have you tried Jetty to test whether it happens in
  it too?
 
  Your fix sounds harmless enough, so I see no reason for it to be
  integrated in Tapestry itself.
 
  And thank you very much for noticing, investigating and provinding a
  solution! :)
 



 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Load test with Tapestry 5.3.4-rc-7 and subtile bug/problem with ResourceStreamerImpl/ResourceChangeTrackerImpl and If-Modified-Since http header

2012-06-28 Thread Howard Lewis Ship
https://issues.apache.org/jira/browse/TAP5-1964

On Thu, Jun 28, 2012 at 6:22 PM, Howard Lewis Ship hls...@gmail.com wrote:

 Ah, reading back, I see exactly what Robert's getting at: the placeholder
 value, used in production, should be limited to one-second precision. This
 represents a change in 5.3 to ditch all the code that checks for changes:
 literally, the filter responsible is not instantiated in production mode,
 and several other services related to propagating events, become no-op
 placeholders.


 On Thu, Jun 28, 2012 at 6:20 PM, Howard Lewis Ship hls...@gmail.comwrote:

 Robert is right on this one; there's code elsewhere to uses the
 URLChangeTracker (the core of ResourceChangeTracker) at second (not
 millisecond) precision, for this exact scenario ...  I suspect something is
 slightly out of wack for it to come back as it has.


 On Thu, Jun 28, 2012 at 4:43 PM, Robert Lentz rob...@teksolv.de wrote:

 Hi Thiago,

 well I don't have jetty available atm, but how would jetty or any other
 java date parser parse a string date including seconds but without
 milliseconds provided to a long milliseconds value

 If-Modified-Since Thu, 28 Jun 2012 22:32:41 GMT


 I assume the millis range 000-999 must be ignored and the long will
 always ends with 000. Anything else is random - right?

 Aloha
  Robert

 Thiago H de Paula Figueiredo schrieb:
  On Thu, 28 Jun 2012 19:38:52 -0300, Robert Lentz rob...@teksolv.de
  wrote:
 
  Hi All,
 
  Hi!
 
  The header If-Modified-Since  which will be parse by Tomcat's
  FastHttpDateFormat.parseDate(..) method to a long, when called
  ifModifiedSince = request.getDateHeader(IF_MODIFIED_SINCE_HEADER).
  During this parsing any milliseconds are ignored/not available,
 
  Isn't this a Tomcat issue instead of a Tapestry one? Of course, we can
  fix in Tapestry's side and that wouldn't be the first time something
  like that happens. Have you tried Jetty to test whether it happens in
  it too?
 
  Your fix sounds harmless enough, so I see no reason for it to be
  integrated in Tapestry itself.
 
  And thank you very much for noticing, investigating and provinding a
  solution! :)
 



 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com




 --
 Howard M. Lewis Ship

 Creator of Apache Tapestry

 The source for Tapestry training, mentoring and support. Contact me to
 learn how I can get you up and productive in Tapestry fast!

 (971) 678-5210
 http://howardlewisship.com




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-06-07 Thread Massimo Lusetti
On Wed, Jun 6, 2012 at 8:16 PM, Howard Lewis Ship hls...@gmail.com wrote:

 I'm writing up a little blog entry on this. I've also created
 5.3.4-rc-5 with even more tweaks.  I'm happy keeping with this
 process, even though were past the number of billable hours we agreed
 to.

Here that is always the case btw.

 BTW, how much memory in your server?

My most recent servers have from 8 to 12 gigs of memory and some share
more then one tapestry applications (most ancient ones are
5.1.0.5-tweaked) but I still run servers with 4

Cheers
-- 
Massimo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-06-07 Thread Howard Lewis Ship
I didn't mean that message to go out to the mailing list.

On Thu, Jun 7, 2012 at 3:11 AM, Massimo Lusetti mluse...@gmail.com wrote:
 On Wed, Jun 6, 2012 at 8:16 PM, Howard Lewis Ship hls...@gmail.com wrote:

 I'm writing up a little blog entry on this. I've also created
 5.3.4-rc-5 with even more tweaks.  I'm happy keeping with this
 process, even though were past the number of billable hours we agreed
 to.

 Here that is always the case btw.

 BTW, how much memory in your server?

 My most recent servers have from 8 to 12 gigs of memory and some share
 more then one tapestry applications (most ancient ones are
 5.1.0.5-tweaked) but I still run servers with 4

 Cheers
 --
 Massimo

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-06-06 Thread Howard Lewis Ship
I'm writing up a little blog entry on this. I've also created
5.3.4-rc-5 with even more tweaks.  I'm happy keeping with this
process, even though were past the number of billable hours we agreed
to.

BTW, how much memory in your server?

On Fri, May 11, 2012 at 6:07 AM, Robert Lentz rob...@teksolv.de wrote:
 Hi All,

 we want to rollout a Tapestry app very shortly, but we struggle with
 load testing issues. We are currently load testing on one Tomcat 6.0.32:
 - 500 worker threads, tapestry.production-mode=true
 - Intel(R) Xeon(R) CPU X7460  @ 2.66GHz
 - OpenJDK Runtime Environment (IcedTea6 1.7.10)
 (rhel-1.20.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16,
 mixed mode))
 and 2 loadrunner test clients.

 After ramping up the concurrent requests (about 5min) we reach the
 maximum at about 450req/sec and get server busy errors. We see a high
 thread contention on InternalComponentResourcesImpl.postRenderCleanup
 currently with the Loop component, as there 10 Loop on the Index page.
 Is there a workaround possible without removing the Loop component from
 the page to increase the throughput? The thread dumps series looks like
 this: 1 thread locks 0xe3858990 and over 400 threads are
 waiting. This lock is persistent over a thread dumps series. I guess the
 private synchronized MapString, Object getRenderVariables(boolean
 create) call hits us.

 http-9080-188 daemon prio=10 tid=0x4d463000 nid=0x382a
 runnable [0x55b2f000]
   java.lang.Thread.State: RUNNABLE
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.getState(ParameterWorker.java:206)
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.reset(ParameterWorker.java:302)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:136)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:133)
    at
 org.apache.tapestry5.internal.util.NamedSet.eachValue(NamedSet.java:171)
    - locked 0xe3858990 (a
 org.apache.tapestry5.internal.util.NamedSet)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.resetParameterConduits(InternalComponentResourcesImpl.java:546)
    - locked 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:522)
    at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
    at
 org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
    at
 org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
    at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
    at $PageRenderQueue_135675e1f6b933.render(Unknown Source)
    at
 org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
 ...
 http-9080-499 daemon prio=10 tid=0x4dffb000 nid=0x3b7d waiting
 for monitor entry [0x69063000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.getRenderVariables(InternalComponentResourcesImpl.java:476)
    - waiting to lock 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:517)
    at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
    at
 org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
    at
 org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
    at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
    at $PageRenderQueue_135675e1f6b933.render(Unknown Source

Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-05-12 Thread Howard Lewis Ship
Yes, I really should have asked you to verify that earlier.  I'm
running the final batch of tests on the 5.4 code, then will be
backporting it as 5.3.4-rc-1.

On Fri, May 11, 2012 at 9:20 PM, Robert Lentz rob...@teksolv.de wrote:
 Forgot to mention that we are using Tapestry 5.3.3.

 Regards
 Robert

 Am 11.05.2012 18:44, schrieb Robert Lentz:
 Howard,

 thank you very much for the quick and insightful response.
 I haven't yet understood the code completely, why that many synchronized
 methods are invoked like ( private synchronized void
 resetParameterConduits() etc)
 I would be really happy to test your  shortly and crank out a
 5.3.4-rc-1 snapshot version as soon as it will be available!
 Let me know, if I can assist you in someway.

 All the Best and Thx
 Robert


 Am 11.05.2012 18:34, schrieb Howard Lewis Ship:
 In case I wasn't clear; I'm waiting for a commitment that you will
 retest with updated Tapestry code before I make the changes.  I'm
 willing to juggle my schedule to assist, if you're ready to do your
 part.


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-05-11 Thread Robert Lentz
Hi All,

we want to rollout a Tapestry app very shortly, but we struggle with
load testing issues. We are currently load testing on one Tomcat 6.0.32:
- 500 worker threads, tapestry.production-mode=true
- Intel(R) Xeon(R) CPU X7460  @ 2.66GHz
- OpenJDK Runtime Environment (IcedTea6 1.7.10)
(rhel-1.20.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16,
mixed mode))
and 2 loadrunner test clients.

After ramping up the concurrent requests (about 5min) we reach the
maximum at about 450req/sec and get server busy errors. We see a high
thread contention on InternalComponentResourcesImpl.postRenderCleanup
currently with the Loop component, as there 10 Loop on the Index page.
Is there a workaround possible without removing the Loop component from
the page to increase the throughput? The thread dumps series looks like
this: 1 thread locks 0xe3858990 and over 400 threads are
waiting. This lock is persistent over a thread dumps series. I guess the
private synchronized MapString, Object getRenderVariables(boolean
create) call hits us.

http-9080-188 daemon prio=10 tid=0x4d463000 nid=0x382a
runnable [0x55b2f000]
   java.lang.Thread.State: RUNNABLE
at
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.getState(ParameterWorker.java:206)
at
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.reset(ParameterWorker.java:302)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:136)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:133)
at
org.apache.tapestry5.internal.util.NamedSet.eachValue(NamedSet.java:171)
- locked 0xe3858990 (a
org.apache.tapestry5.internal.util.NamedSet)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.resetParameterConduits(InternalComponentResourcesImpl.java:546)
- locked 0xe385c038 (a
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:522)
at
org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
at $PageRenderQueue_135675e1f6b933.render(Unknown Source)
at
org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
...
http-9080-499 daemon prio=10 tid=0x4dffb000 nid=0x3b7d waiting
for monitor entry [0x69063000]
   java.lang.Thread.State: BLOCKED (on object monitor)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.getRenderVariables(InternalComponentResourcesImpl.java:476)
- waiting to lock 0xe385c038 (a
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
at
org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:517)
at
org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
at
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
at $PageRenderQueue_135675e1f6b933.render(Unknown Source)
at
org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
...
Additionally we experienced a similar issue when using a component with
a mixin annotation in a loop, that was rendered more than 20 times on
the page.
The contention here was on the
org.apache.tapestry5.internal.util.NamedSet.getValues call

http-9080-79

Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-05-11 Thread Howard Lewis Ship
That's an interesting result.  Why, oh why, did I ever implement
render variables?

So the conventional thinking on synchronized methods is that they
where there is limited contention, and the method is short,
synchronized is the best way to go.

This method exists, and is synchronized, to avoid creating a
PerThreadValue to store the render variable's Map on every component
and mixin in the application.  That adds up, given that only a tiny
percentage of pages or components will ever use a render variable.

I'd be willing to replace this code with something that uses an
explicit per-instance Lock ... that would likely help with your high
contention issues, as after the PerThreadValue is created, and the
write lock is released, there would no longer be contention, as all
threads could share the read lock.

I can put that together shortly and crank out a 5.3.4-rc-1 snapshot,
if you can then pick it up and test it.

Further comments here: https://issues.apache.org/jira/browse/TAP5-1929

On Fri, May 11, 2012 at 6:07 AM, Robert Lentz rob...@teksolv.de wrote:
 Hi All,

 we want to rollout a Tapestry app very shortly, but we struggle with
 load testing issues. We are currently load testing on one Tomcat 6.0.32:
 - 500 worker threads, tapestry.production-mode=true
 - Intel(R) Xeon(R) CPU X7460  @ 2.66GHz
 - OpenJDK Runtime Environment (IcedTea6 1.7.10)
 (rhel-1.20.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16,
 mixed mode))
 and 2 loadrunner test clients.

 After ramping up the concurrent requests (about 5min) we reach the
 maximum at about 450req/sec and get server busy errors. We see a high
 thread contention on InternalComponentResourcesImpl.postRenderCleanup
 currently with the Loop component, as there 10 Loop on the Index page.
 Is there a workaround possible without removing the Loop component from
 the page to increase the throughput? The thread dumps series looks like
 this: 1 thread locks 0xe3858990 and over 400 threads are
 waiting. This lock is persistent over a thread dumps series. I guess the
 private synchronized MapString, Object getRenderVariables(boolean
 create) call hits us.

 http-9080-188 daemon prio=10 tid=0x4d463000 nid=0x382a
 runnable [0x55b2f000]
   java.lang.Thread.State: RUNNABLE
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.getState(ParameterWorker.java:206)
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.reset(ParameterWorker.java:302)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:136)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:133)
    at
 org.apache.tapestry5.internal.util.NamedSet.eachValue(NamedSet.java:171)
    - locked 0xe3858990 (a
 org.apache.tapestry5.internal.util.NamedSet)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.resetParameterConduits(InternalComponentResourcesImpl.java:546)
    - locked 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:522)
    at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
    at
 org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
    at
 org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
    at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
    at $PageRenderQueue_135675e1f6b933.render(Unknown Source)
    at
 org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
 ...
 http-9080-499 daemon prio=10 tid=0x4dffb000 nid=0x3b7d waiting
 for monitor entry [0x69063000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.getRenderVariables(InternalComponentResourcesImpl.java:476)
    - waiting to lock 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:517)
    at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
    at
 org.apache.tapestry5

Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-05-11 Thread Denis Stepanov
Would it be better to put synchronized block inside null check block like:

if (renderVariables == null) { synchronized(this) { ...

If I'm not mistaken resetParametersConduits doesn't need to be synchronized it 
should only change per thread value.

Denis

May 11, 2012 v 6:06 PM, Howard Lewis Ship:

 That's an interesting result.  Why, oh why, did I ever implement
 render variables?
 
 So the conventional thinking on synchronized methods is that they
 where there is limited contention, and the method is short,
 synchronized is the best way to go.
 
 This method exists, and is synchronized, to avoid creating a
 PerThreadValue to store the render variable's Map on every component
 and mixin in the application.  That adds up, given that only a tiny
 percentage of pages or components will ever use a render variable.
 
 I'd be willing to replace this code with something that uses an
 explicit per-instance Lock ... that would likely help with your high
 contention issues, as after the PerThreadValue is created, and the
 write lock is released, there would no longer be contention, as all
 threads could share the read lock.
 
 I can put that together shortly and crank out a 5.3.4-rc-1 snapshot,
 if you can then pick it up and test it.
 
 Further comments here: https://issues.apache.org/jira/browse/TAP5-1929
 
 On Fri, May 11, 2012 at 6:07 AM, Robert Lentz rob...@teksolv.de wrote:
 Hi All,
 
 we want to rollout a Tapestry app very shortly, but we struggle with
 load testing issues. We are currently load testing on one Tomcat 6.0.32:
 - 500 worker threads, tapestry.production-mode=true
 - Intel(R) Xeon(R) CPU X7460  @ 2.66GHz
 - OpenJDK Runtime Environment (IcedTea6 1.7.10)
 (rhel-1.20.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16,
 mixed mode))
 and 2 loadrunner test clients.
 
 After ramping up the concurrent requests (about 5min) we reach the
 maximum at about 450req/sec and get server busy errors. We see a high
 thread contention on InternalComponentResourcesImpl.postRenderCleanup
 currently with the Loop component, as there 10 Loop on the Index page.
 Is there a workaround possible without removing the Loop component from
 the page to increase the throughput? The thread dumps series looks like
 this: 1 thread locks 0xe3858990 and over 400 threads are
 waiting. This lock is persistent over a thread dumps series. I guess the
 private synchronized MapString, Object getRenderVariables(boolean
 create) call hits us.
 
 http-9080-188 daemon prio=10 tid=0x4d463000 nid=0x382a
 runnable [0x55b2f000]
   java.lang.Thread.State: RUNNABLE
at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.getState(ParameterWorker.java:206)
at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.reset(ParameterWorker.java:302)
at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:136)
at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:133)
at
 org.apache.tapestry5.internal.util.NamedSet.eachValue(NamedSet.java:171)
- locked 0xe3858990 (a
 org.apache.tapestry5.internal.util.NamedSet)
at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.resetParameterConduits(InternalComponentResourcesImpl.java:546)
- locked 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:522)
at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
at
 org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
at
 org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
at $PageRenderQueue_135675e1f6b934.render(Unknown Source)
at $PageRenderQueue_135675e1f6b933.render(Unknown Source)
at
 org.apache.tapestry5.internal.services.MarkupRendererTerminator.renderMarkup(MarkupRendererTerminator.java:37)
 ...
 http-9080-499 daemon prio=10 tid=0x4dffb000 nid=0x3b7d waiting
 for monitor entry [0x69063000]
   java.lang.Thread.State: BLOCKED (on object monitor)
at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.getRenderVariables(InternalComponentResourcesImpl.java:476)
- waiting to lock 0xe385c038 (a
 org.apache.tapestry5

Re: high thread contention during load test on InternalComponentResourcesImpl.postRenderCleanup and org.apache.tapestry5.internal.util.NamedSet.getValues

2012-05-11 Thread Howard Lewis Ship
That's a common mistake.  Although I've heard that future JDK/JVM may
address this common case, it is not valid to read a shared variable
outside a synchronized block, even to check for null-ness.  This was a
common mistake propagated in books and blogs in the early 2000's.

Another alternative would be to make the field final and assign it in
the constructor, but that means you will have 1000's (or 10,000's) of
these floating around doing nothing. I've been working to make
Tapestry's runtime profile slimmer, so that would be a step backwards.

On Fri, May 11, 2012 at 9:16 AM, Denis Stepanov
denis.stepa...@gmail.com wrote:
 Would it be better to put synchronized block inside null check block like:

 if (renderVariables == null) { synchronized(this) { ...

 If I'm not mistaken resetParametersConduits doesn't need to be synchronized 
 it should only change per thread value.

 Denis

 May 11, 2012 v 6:06 PM, Howard Lewis Ship:

 That's an interesting result.  Why, oh why, did I ever implement
 render variables?

 So the conventional thinking on synchronized methods is that they
 where there is limited contention, and the method is short,
 synchronized is the best way to go.

 This method exists, and is synchronized, to avoid creating a
 PerThreadValue to store the render variable's Map on every component
 and mixin in the application.  That adds up, given that only a tiny
 percentage of pages or components will ever use a render variable.

 I'd be willing to replace this code with something that uses an
 explicit per-instance Lock ... that would likely help with your high
 contention issues, as after the PerThreadValue is created, and the
 write lock is released, there would no longer be contention, as all
 threads could share the read lock.

 I can put that together shortly and crank out a 5.3.4-rc-1 snapshot,
 if you can then pick it up and test it.

 Further comments here: https://issues.apache.org/jira/browse/TAP5-1929

 On Fri, May 11, 2012 at 6:07 AM, Robert Lentz rob...@teksolv.de wrote:
 Hi All,

 we want to rollout a Tapestry app very shortly, but we struggle with
 load testing issues. We are currently load testing on one Tomcat 6.0.32:
 - 500 worker threads, tapestry.production-mode=true
 - Intel(R) Xeon(R) CPU X7460  @ 2.66GHz
 - OpenJDK Runtime Environment (IcedTea6 1.7.10)
 (rhel-1.20.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16,
 mixed mode))
 and 2 loadrunner test clients.

 After ramping up the concurrent requests (about 5min) we reach the
 maximum at about 450req/sec and get server busy errors. We see a high
 thread contention on InternalComponentResourcesImpl.postRenderCleanup
 currently with the Loop component, as there 10 Loop on the Index page.
 Is there a workaround possible without removing the Loop component from
 the page to increase the throughput? The thread dumps series looks like
 this: 1 thread locks 0xe3858990 and over 400 threads are
 waiting. This lock is persistent over a thread dumps series. I guess the
 private synchronized MapString, Object getRenderVariables(boolean
 create) call hits us.

 http-9080-188 daemon prio=10 tid=0x4d463000 nid=0x382a
 runnable [0x55b2f000]
   java.lang.Thread.State: RUNNABLE
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.getState(ParameterWorker.java:206)
    at
 org.apache.tapestry5.internal.transform.ParameterWorker$3$1.reset(ParameterWorker.java:302)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:136)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.work(InternalComponentResourcesImpl.java:133)
    at
 org.apache.tapestry5.internal.util.NamedSet.eachValue(NamedSet.java:171)
    - locked 0xe3858990 (a
 org.apache.tapestry5.internal.util.NamedSet)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.resetParameterConduits(InternalComponentResourcesImpl.java:546)
    - locked 0xe385c038 (a
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl)
    at
 org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl.postRenderCleanup(InternalComponentResourcesImpl.java:522)
    at
 org.apache.tapestry5.corelib.components.Loop.postRenderCleanup(Loop.java)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$1.run(ComponentPageElementImpl.java:85)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:956)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$1800(ComponentPageElementImpl.java:61)
    at
 org.apache.tapestry5.internal.structure.ComponentPageElementImpl$PostRenderCleanupPhase.render(ComponentPageElementImpl.java:443)
    at
 org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
    at
 org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java

  1   2   3   >