Slick FAIL TO PARSE TILEMAP - slick

I encountered another problem while learning to work with slick library.
I created a simple little map with 5x5 blocks with size 50x50 pixel.
I tried everything but I still get the same error.
Here my class:
public class PlayState extends BasicGameState{
int stateID = -1;
private TiledMap map;
public PlayState(int stateID){
this.stateID = stateID;
}
#Override
public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
map = new TiledMap("src/resources/map.tmx","src/resources");
}
#Override
public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
map.render(0, 0);
}
#Override
public void update(GameContainer gc, StateBasedGame sbg, int arg2) throws SlickException {
}
#Override
public int getID() {
return stateID;
}
}
and here my error:
Tue Jul 30 13:34:09 CEST 2013 INFO:Slick Build #237
Tue Jul 30 13:34:09 CEST 2013 INFO:LWJGL Version: 2.9.0
Tue Jul 30 13:34:09 CEST 2013 INFO:OriginalDisplayMode: 1600 x 900 x 32 #60Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:TargetDisplayMode: 1280 x 720 x 0 #0Hz
Tue Jul 30 13:34:09 CEST 2013 INFO:Starting display 1280x720
Tue Jul 30 13:34:09 CEST 2013 INFO:Use Java PNG Loader = true
Tue Jul 30 13:34:09 CEST 2013 INFO:Controllers not available
Tue Jul 30 13:34:09 CEST 2013 WARN:class org.newdawn.slick.opengl.PNGImageData failed to read the data
java.io.IOException: Transparent color not support in custom PNG Decoder
at org.newdawn.slick.opengl.PNGImageData.loadImage(PNGImageData.java:78)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:62)
at org.newdawn.slick.opengl.CompositeImageData.loadImage(CompositeImageData.java:43)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:292)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:187)
at org.newdawn.slick.Image.<init>(Image.java:192)
at org.newdawn.slick.tiled.TileSet.<init>(TileSet.java:124)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:661)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Unsupport tiled map type: base64,zlib (only gzip base64 supported)
org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Tue Jul 30 13:34:09 CEST 2013 ERROR:Failed to parse tilemap
org.newdawn.slick.SlickException: Failed to parse tilemap
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:695)
at org.newdawn.slick.tiled.TiledMap.<init>(TiledMap.java:122)
at main.states.PlayState.init(PlayState.java:23)
at org.newdawn.slick.state.StateBasedGame.init(StateBasedGame.java:171)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:393)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:317)
at main.Main.main(Main.java:40)
Caused by: org.newdawn.slick.SlickException: Unsupport tiled map type: base64,zlib (only gzip base64 supported)
at org.newdawn.slick.tiled.Layer.<init>(Layer.java:133)
at org.newdawn.slick.tiled.TiledMap.load(TiledMap.java:676)
... 6 more

I just got this error myself - and solved it. You need to make sure your map properties layer format is set to Base64 (gzip compressed). Looks like that's the format slick expects.
As far as the PNG warnings, apparently slick doesn't like interlaced PNG files, so save as a non-interlaced image

Related

Using Jscript i want to change 2022-10-20T14:54:29.255+0800 to 13/10/2022 2:54 PM

i tried using this method :
newDateTime = new Date('2022-10-20T14:54:29.255+0800');
but it return me : "Thu Oct 20 2022 14:54:29 GMT+0800 (Singapore Standard Time)"

SOUP UI Groovy || For loop is looping 50 times where the condition is using this number anywhere

Here I am just taking value(integer) from Properties file and using the same in for loop.
Note : If I use direct number instead of "getTestCasePropertyValue" value it work as expected. Not getting how loop is looping it 50 times.
Groovy script:
def getTestCasePropertyValue = testRunner.testCase.getPropertyValue( "NumOfPayments" )
log.info(getTestCasePropertyValue )
for(i=0; i<=getTestCasePropertyValue; i++)
{
log.info("Test Print"+i)
}
Output:
Fri Mar 06 12:58:47 IST 2020:INFO:2
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print0
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print1
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print2
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print3
...
Fri Mar 06 12:58:47 IST 2020:INFO:Test Print50
Your value from the properties is a String. You will detect problems like this easier, if you use .inspect() to log things.
Also the character '2' is 50 as integer, which then the for loop conditions casts this too.
def getTestCasePropertyValue = "2"
println(getTestCasePropertyValue.inspect())
// → '2'
println(getTestCasePropertyValue as char as int)
// → 50
So best explicitly cast to a number using e.g. .toLong() on the string:
println(getTestCasePropertyValue.toLong().inspect())
// → 2

string comparison does not match but 'contains' does

I have a strange problem using groovy, I found a workaround but I'm quite not satisfied so maybe someone will be able to help me:
I use ReadyAPI 2.8. In my test cases I have groovy steps.
In one of those, I recover a String from a previous test step and I want to do a particular processing if it matches the string "TJA470". The previous test step gives a string that is the output of a ssh command.
here is the groovy step code :
def hbox_ref = context.expand( '${get current HBox reference#hbox_ref}' )
// this returns me the data as a String
log.info hbox_ref
log.info "\"$hbox_ref\"" // to check if there is no spurious blank
log.info hbox_ref.class
log.info (hbox_ref == "TJA470") => returns false
log.info (hbox_ref.equals("TJA470")) => returns false
log.info (hbox_ref.contains("TJA470")) => returns true
here is the console result :
Fri Sep 20 16:13:17 CEST 2019: INFO: TJA470
Fri Sep 20 16:13:17 CEST 2019: INFO: "TJA470
"
Fri Sep 20 16:13:17 CEST 2019: INFO: class java.lang.String
Fri Sep 20 16:13:17 CEST 2019: INFO: false
Fri Sep 20 16:13:17 CEST 2019: INFO: false
Fri Sep 20 16:13:17 CEST 2019: INFO: true
The straighforward test is == or equals though there are differences, I use those in all the other comparisons of the same type and it works.
As you can see here the most logic cases return false and I really can't work out why.
If I do the same script in a tool like 'groovy playground' it works as expected ! :(
I'm not an expert in groovy at all and there must be something that I missed, but I find it very tricky !
If anyone can help ...
thanks
Thanks to SO I found out the problem :
with copy/pasting the console return in the question, it shows that there is a special character at the end of the text. This is not visible in SOAPUI log output ...
I added the following processing in my script :
def hbox_ref = context.expand( '${get current HBox reference#hbox_ref}' )
hbox_ref = hbox_ref.replaceAll("[^a-zA-Z0-9]+","")
or
hbox_ref = hbox_ref.replaceAll("[^\\w]+","")
this gives
log.info (hbox_ref == "TJA470") => returns true (at last !)
more elegant solution (thanks to SiKing) :
(hbox_ref.trim() == "TJA470")
instead of using replaceAll

rerun a test case in ready api using tear down script

I have a test case "Login" which intermittently fails due to login issues.
I would like to implement a tear down script to get the status of the script and rerun if it failed.
Here is what I implemented and it doesn't work as expected.
testRunner.testCase.setPropertyValue("LoginStatus",
testRunner.getStatus().toString())
def loginStatus = context.expand( '${#TestCase#LoginStatus}' )
int retryAttempts = context.expand( '${#Project#RetryAttempts}' ).toInteger()
def myContext = (com.eviware.soapui.support.types.StringToObjectMap)context
while ( loginStatus == "FAIL" && retryAttempts <= 1) {
retryAttempts = retryAttempts+1
log.info "increment retry attempts-" + retryAttempts
testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts",
retryAttempts.toString() )
testCase.run(myContext, false)
log.info "after run statement-"+retryAttempts
}
log.info "before final statement"
testRunner.testCase.testSuite.project.setPropertyValue( "RetryAttempts", "0"
)
The script runs 3 times even though it is configured to rerun once. The logs
Fri May 18 13:55:15 EDT 2018:INFO:increment retry attempts-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:16 EDT 2018:INFO:before final statement
Fri May 18 13:55:16 EDT 2018:INFO:after run statement-1
Fri May 18 13:55:16 EDT 2018:INFO:increment retry attempts-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement
Fri May 18 13:55:17 EDT 2018:INFO:after run statement-2
Fri May 18 13:55:17 EDT 2018:INFO:before final statement

Fuse Example File System - The file changed on disk do you want to reload the file

Running built-in fuse HelloFS example file system, shows a hello.txt file on root.
Opening this file show an error as "...The file changed on disk do you want to reload the file. Reload/cancel"
How can I remove this error.
I am facing the same error in my custom File System because I had taken HelloFS as starting point. To make question simple I quoted HelloFS code because the same error is in helloFS also.
example code, log and screenshot of error are as below:
HelloFS java Code:
package net.fusejna.examples;
import java.io.File;
import java.nio.ByteBuffer;
import net.fusejna.DirectoryFiller;
import net.fusejna.ErrorCodes;
import net.fusejna.FuseException;
import net.fusejna.StructFuseFileInfo.FileInfoWrapper;
import net.fusejna.StructStat.StatWrapper;
import net.fusejna.types.TypeMode.NodeType;
import net.fusejna.util.FuseFilesystemAdapterFull;
public class HelloFS extends FuseFilesystemAdapterFull
{
public static void main(final String... args) throws FuseException
{
if (args.length != 1) {
System.err.println("Usage: HelloFS <mountpoint>");
System.exit(1);
}
new HelloFS().log(true).mount(args[0]);
}
private final String filename = "/hello.txt";
private final String contents = "Hello World!\n";
#Override
public int getattr(final String path, final StatWrapper stat)
{
if (path.equals(File.separator)) { // Root directory
stat.setMode(NodeType.DIRECTORY);
return 0;
}
if (path.equals(filename)) { // hello.txt
stat.setMode(NodeType.FILE).size(contents.length());
return 0;
}
return -ErrorCodes.ENOENT();
}
#Override
public int read(final String path, final ByteBuffer buffer, final long size, final long offset, final FileInfoWrapper info)
{
// Compute substring that we are being asked to read
final String s = contents.substring((int) offset,
(int) Math.max(offset, Math.min(contents.length() - offset, offset + size)));
buffer.put(s.getBytes());
return s.getBytes().length;
}
#Override
public int readdir(final String path, final DirectoryFiller filler)
{
filler.add(filename);
return 0;
}
}
error: ...The file changed on disk do you want to reload the file. Reload/cancel
log:
Mar 24, 2014 12:16:15 AM HelloFS statfs
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:33 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:36 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS open
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS read
INFO: [/hello.txt] Method succeeded. Result: 13
Mar 24, 2014 12:16:45 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS flush
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:45 AM HelloFS lock
INFO: [/hello.txt] Method succeeded. Result: -38
Mar 24, 2014 12:16:45 AM HelloFS release
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:46 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Mar 24, 2014 12:16:46 AM HelloFS getattr
INFO: [/] Method succeeded. Result: 0
Mar 24, 2014 12:16:48 AM HelloFS getattr
INFO: [/hello.txt] Method succeeded. Result: 0
Please Guide me how to fix this
I am not as familiar with the Java version of FUSE (I mostly do C++/Python), but based on your trace, I'd say that your editor application is the one releasing the file handle. Maybe it's doing something like open/read/close, and then holding it in cache. Try opening the file in something even simpler, like vi, or using cat on it.
The thing about "the contents have changed on disk" is probably your editor responding to a continuously changing timestamp in your stat structure. Try setting your StatWrapper.mtime (in your getattr function) to some fixed time, like unix epoch, and see if that helps.
The example file systems are a good jumping off point, but in order to be easy to understand, there's often a lot they don't implement.

Resources