Hi! On the server side, we're using DSRequest objects. In my junit test method, I'm creating a DSRequest object, using the constructor that passes in the datasource name and the operation type (OP_ADD or OP_UPDATE). I'm also calling dsRequest.setValue passing in a Map of values to create the object. The problem is that when it gets to the part of the real code where I have the "dsRequest.getDataSource()" statement, it throws an Exception. This only happens with the junit method, not in the real app. How do I setup DSRequest obejct in the junit method so that dsRequest.getDataSource() will not throw an Exception?
Announcement
Collapse
No announcement yet.
X
-
I'm also trying to create a JUnit test to test a data source on the server side. I've changed my server.properties webroot setting to point to the file system path where the smartgwtpower.jar and other Iso jars are. What additional setup is needed?
Here is my test case code.
Code:package com.islandpacific.gui.server.test; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import com.isomorphic.base.ISCInit; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; public class IpPkdefTest extends TestCase { public void test1() throws Exception { ISCInit.go(); DSRequest req = new DSRequest("IPPKDEF", "fetch"); req.setOperationId("commonSKU"); req.addToTemplateContext("csLib", "IPTSFILZ"); Map criteria = new HashMap(); criteria.put("PKCLS", 280); criteria.put("PKVEN", 280); criteria.put("PKSTY", 124); criteria.put("PKCLR", 100); criteria.put("PKSIZ", 1000); req.setCriteria(criteria); DSResponse resp = req.execute(); System.out.println(resp.getRecords()); } }
Code:java.io.IOException: Configured for containerIO, but servletContext not available! You need to install the Init servlet at com.isomorphic.io.ISCFile.<init>(ISCFile.java:139) at com.isomorphic.store.DataStructCache.XMLOrJSFile(DataStructCache.java:274) at com.isomorphic.store.DataStructCache._getInstanceFile(DataStructCache.java:237) at com.isomorphic.store.DataStructCache.getInstanceFile(DataStructCache.java:190) at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:63) at com.isomorphic.datasource.DataSource.forName(DataSource.java:156) at com.isomorphic.datasource.DataSource.forName(DataSource.java:148) at com.isomorphic.datasource.DataSource.forName(DataSource.java:143) at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:95) at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:102) at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:82) at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:62) at com.isomorphic.datasource.DSRequest.getDataSource(DSRequest.java:1281) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:1362) at com.islandpacific.gui.server.test.IpPkdefTest.test1(IpPkdefTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:76) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Code:ISC: Configuring log4j from: file:/Users/jfisher/helios/workspace/IPGui/war/WEB-INF/classes/log4j.isc.config.xml === 2011-02-02 10:48:08,179 [main] INFO ISCInit - Isomorphic SmartClient Framework - Initializing === 2011-02-02 10:48:08,185 [main] INFO ConfigLoader - Attempting to load framework.properties from CLASSPATH === 2011-02-02 10:48:08,292 [main] INFO ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/Users/jfisher/helios/workspace/IPGui/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties === 2011-02-02 10:48:08,292 [main] INFO ConfigLoader - Attempting to load project.properties from CLASSPATH === 2011-02-02 10:48:08,298 [main] INFO ConfigLoader - Unable to locate project.properties in CLASSPATH === 2011-02-02 10:48:08,306 [main] INFO ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/Users/jfisher/helios/workspace/IPGui/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties === 2011-02-02 10:48:08,307 [main] INFO ConfigLoader - Attempting to load server.properties from CLASSPATH === 2011-02-02 10:48:08,317 [main] INFO ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/Users/jfisher/helios/workspace/IPGui/war/WEB-INF/classes/server.properties === 2011-02-02 10:48:08,325 [main] INFO Logger - Logging system started. === 2011-02-02 10:48:08,326 [main] INFO ISCInit - Isomorphic SmartClient Framework (SC_SNAPSHOT-2011-01-29/PowerEdition Deployment 2011-01-29) - Initialization Complete === 2011-02-02 10:48:08,327 [main] INFO ISCInit - No ServletContext available yet - using container IO for now === 2011-02-02 10:48:08,343 [main] INFO ISCInit - No ServletContext available yet - using container IO for now === 2011-02-02 10:48:08,409 [main] INFO PoolManager - SmartClient pooling disabled for 'IPPKDEF' objects === 2011-02-02 10:48:08,448 [main] INFO RepoRegistry - RepoRegistry unavailable: can't find RepoRegistry.ds.xml - using datasources.repo.default
Comment
-
This got me as well. There is no servlet context. Do I need to run a servlet environment (like this: http://jakarta.apache.org/cactus/wri..._testcase.html ) to run tests that use DataSources?
Code:ISC: Configuring log4j from: file:/workspace/project/war/WEB-INF/classes/log4j.isc.config.xml === 2011-08-09 08:37:15,045 [main] INFO ISCInit - Isomorphic SmartClient Framework - Initializing === 2011-08-09 08:37:15,053 [main] INFO ConfigLoader - Attempting to load framework.properties from CLASSPATH === 2011-08-09 08:37:15,160 [main] INFO ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/workspace/project/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties === 2011-08-09 08:37:15,160 [main] INFO ConfigLoader - Attempting to load project.properties from CLASSPATH === 2011-08-09 08:37:15,161 [main] INFO ConfigLoader - Unable to locate project.properties in CLASSPATH === 2011-08-09 08:37:15,164 [main] INFO ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/workspace/project/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties === 2011-08-09 08:37:15,164 [main] INFO ConfigLoader - Attempting to load server.properties from CLASSPATH === 2011-08-09 08:37:15,167 [main] INFO ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/workspace/project/war/WEB-INF/classes/server.properties === 2011-08-09 08:37:15,172 [main] INFO Logger - Logging system started. === 2011-08-09 08:37:15,172 [main] INFO ISCInit - Isomorphic SmartClient Framework (SC_SNAPSHOT-2011-08-02/Pro Deployment 2011-08-02) - Initialization Complete === 2011-08-09 08:37:15,173 [main] INFO ISCInit - No ServletContext available yet - using container IO for now === 2011-08-09 08:37:15,448 [main] INFO ISCInit - No ServletContext available yet - using container IO for now Problem loading builtinTypes.xml Exception when loading from __USE_CONTAINER__/KISS/sc/system/schema/builtinTypes.xml: java.io.IOException: Configured for containerIO, but servletContext not available! You need to install the Init servlet at com.isomorphic.io.ISCFile.<init>(ISCFile.java:139) at com.isomorphic.store.ProcessedFileCache.getObjectFromFile(ProcessedFileCache.java:138)
Comment
-
It turns out my problem was having a space in my project's path name.
Is there any easy way to have two server.properties files? (one that specifies webRoot as the local machine path and one that specifies __AUTODETECT__) I guess I can do this by creating a new project and linking the source files from the old project.
Comment
-
Hi,
using 3.0
I tried both,
Init.go() + new DSReqest("datasource.ds.xml", "add");
and
DataSourceManager.get("datasource.ds.xml")
and got
=== 2011-11-16 09:47:56,271 [main] INFO ISCInit - No ServletContext available yet - using container IO for now
Problem loading builtinTypes.xml
Exception when loading from __USE_CONTAINER__/portal/sc/system/schema/builtinTypes.xml:
java.io.IOException: Configured for containerIO, but servletContext not available! You need to install the Init servlet
You can help me out, how to solve this?
The Test should read the same server.properties, which is used for application
Comment
Comment