There is an false error output on #Override. How do I fix it? - minecraft

So yeah, I have an issue where I can't test my Minecraft mod, and it does not explain what's the cause. I've done it correctly, yet I can't get over this error. Its a toilet mod. IDE I use is IntelliJ. It's also on fabric, if you are a forge modder. There's no further explanation.
The error
This is the output I get. The output just shows me the error, and I've tried the suggestions, but it seems to worsen
#Override
public void onInitialize() {
Registry.register(Registry.BLOCK, new Identifier("toilet", "ceramic_toilet"), CERAMIC_TOILET);
Registry.register(new Identifier("toilet", "ceramic_toilet"), new BlockItem(CERAMIC_TOILET, new Item.Settings().group((ItemGroup.MISC)));
}
}

Given the information you provide, as Joseph Sible-Reinstate Monica suggests: it's a syntax error.
The #Override annotation should not have a semicolon after it.
Also your second register method is missing a closing bracket, add another one like so:
Registry.register(new Identifier("toilet", "ceramic_toilet"), new BlockItem(CERAMIC_TOILET, new Item.Settings().group((ItemGroup.MISC))));

Related

E2E testing multiple posibilities with exception

i have a problem that i don't exactly know how to solve. I'm implementing an E2E test in which using selenium i need to click in a Link and check that is sending me to the right URL.
Here starts the problem...
There are 3 possibilities, mix of 2 types of links, just one type of link or the other type of link. No problems with the situations in which there are both types of links but when there is just one type when it searches for the identifier we use for the links that are not in page it gives me a timeoutException. This is not a failure because it's a posible situation but i will like to know if there is a way in which to check that if it finds no links it asserts that the exception is thrown.
I though using a runCatching (or try catch) wait for the link to appear and if it doesn't appear the test asserts that when i look for the element the timeout exception is thrown again.
It smells a bit for me this way of doing it and i don't know if it's correctly done.
EDIT: Im ussing AssertK and JUnit5 for testing.
EDIT 2: I've done this, i dont know if it a correct way of doing it
runCatching {
driver.waitFor(numberOfWidgetsToBeMoreThan(BrowserSelector.cssSelector(OFFERS_WITH_PRICE_AND_DATE), 0), ofMillis(2000))
}.onFailure {
assertThrows<WaitTimeoutException> {
findLink(OFFERS_WITH_PRICE_AND_DATE)
}
}.onSuccess {
val widget = findLink(OFFERS_WITH_PRICE_AND_DATE)
widget.click()
assertThat(driver.url).contains(NO_DATE_TEXT)
}
I'm not sure I understood your problem correctly, but you can use assertFails to assert that a piece of code throws an exception:
#Test
fun test() {
val exception = assertFails {
// some code that should throw
}
// some more assertions on the type of exception etc. may go here
}

CodenameOne TestRecorder How-To run test

because I think I recommend CodenameOne to be used for development I try to investigate deeper into it. I just tried out the Test Recorder which generated a test class.
Now my question: How-to use this test class? Do I have to call the test method from the existing UI code using e.g. a button to start it?
Generated code:
public class RegisterUserATest extends AbstractTest {
public boolean runTest() throws Exception {
clickButtonByName("Register");
keyPress(16);
keyPress(65);
waitFor(112);
keyPress(65);
setText("Name", "A");
keyPress(16);
keyPress(65);
waitFor(113);
keyPress(16);
waitFor(1);
keyPress(97);
setText("Email", "");
setText("Password", "A");
clickButtonByName("Register");
return true;
}
}
I think the solution is very easy but I cannot see it.
If this is on NetBeans right click the project and select "Test". On IntelliJ/IDEA it's under Codename One -> Run Tests.
Notice that the latter has a bug in it that will be fixed in the release coming tomorrow (October 7th 2016).

Duplicate entry in Aspectj

When I try to weave the jar file using Aspectj code, I am getting
java.util.zip.ZipException: duplicate entry org/apache/pig/backend/hadoop/execu
tionengine/physicalLayer/expressionOperators/Add.class
I used the following command to weave the jar file
ajc -inpath C:\pig.jar -aspectpath C:\Aspects.jar -extdirs C:\libs -outjar C:\pig\pig.jar
Can any one tell me why?
Well, first of all ajc does not know any -extdirs paramater, AFAIK.
I also find it rather strange that your outjar has the same name as the injar, just in another subdirectory. This makes it easy to mistake one for another when weaving the next time or just using the library.
The "duplicate entry" thing maybe comes from the same class being contained in pig.jar and Aspects.jar. The "maybe" was a wrong guess, see discussion between Andy Clement and me in the comments section below. The true cause is described in update 2.
Update:
So how can it happen that the exception you mention happens while packaging the outjar?
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
public class ZipExceptionDemo {
public static void main(String[] args) throws IOException {
try (JarOutputStream stream = new JarOutputStream(new FileOutputStream("foo.jar"))) {
stream.putNextEntry(new ZipEntry("com/foo/One.class"));
stream.putNextEntry(new ZipEntry("com/foo/Two.class"));
stream.putNextEntry(new ZipEntry("com/foo/UhOh.class"));
stream.putNextEntry(new ZipEntry("com/foo/UhOh.class")); // uh-oh!
}
}
}
Exception in thread "main" java.util.zip.ZipException: duplicate entry: com/foo/UhOh.class
at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:215)
at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
at ZipExceptionDemo.main(ZipExceptionDemo.java:12)
Now your job is to find out why you have the same class in multiple JARs you want to mix into one. You even know which one to search for: org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.Add.
Update 2:
I have been able to reproduce the problem with two JARs or directories on the inpath containing the same class file. How you were able to get that error if your commandline really only has a single entry on the inpath as shown in your question, remains a mystery to me. Anyway, I have filed a bug ticket for the problem.

How can you use SessionAsSigner in a Java Bean called from an XPage?

According to Phillip Riand (see: discussion on openNTF) this is not possible... They need to know the design element to find out who signed it. Therefore, it is only available in SSJS.
There are 2 ways that I know of to use the sessionAsSigner object in Java beans:
1 By resolving the sessionAsSigner object:
FacesContext context = FacesContext.getCurrentInstance();
Session sessionAsSigner = context.getApplication().getVariableResolver().
resolveVariable(context, "sessionAsSigner");
2 By using the getCurrentSessionAsSigner() function from the com.ibm.xsp.extlib.util.ExtLibUtil class in the Extension Library.
To be able to use it (in Java as wel as SSJS) you'll want to make sure that all design elements were signed by the same user ID. If that's not the case, the sessionAsSigner object will not be available ('undefined').
I found that the solution is right at hand :-)
I changed my XPage (in this example an XAgent) to:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
This is an xAgent returning json data...
<xp:this.afterRenderResponse><![CDATA[#{javascript:Controller.verify(sessionAsSigner)}]]></xp:this.afterRenderResponse>
and in the bean I simply used the session in the argument when I needed to open a database/document as signer. Sometimes the solution is so simple :-)
/John
This is quite an old post that I just stumbled upon. Tried some of the solutions mentioned above:
resolveVariable did not work for me, at least not for sessionAsSigner as this throws a runtime error (I can resolve plain old session, though...)
to be honest I didn't quite understand the Controller.verify(sessionAsSigner) method; is Controller something specific to XAgents? If so, I don't have an XAgent here, so can't use it
didn't feel like importing extra ExtLib classes here...
So I came up with another solution that appears to be very simple:
created a method in my javaBean that takes a session object as argument; since sessionAsSigner belongs to the same class as session I don't have to import something new.
Javacode is:
public void testSession(Session s) throws Exception{
System.out.println(" > test effective user for this session = "
+ s.getEffectiveUserName());
}
This is called from SSJS as either
mybean.testSession(session);
or
myBean.testSession(sessionAsSigner);
Maybe helps others, too

Apache Error is incompatible with throws class

I've got a quick question. In my grails project I am making some web service calls. One of the calls (for a search function) tends to timeout if not enough characters are given to search for. I can't increase the number of required characters so I instead am trying to catch the exception and display an error page asking the user to add more detailed parameters.
The method looks like this:
import org.apache.http.client.HttpResponseException
class RestSearchService implements SearchService {
List<Person> getPersonSearch( String fName, String lName) throws HttpResponseException {
...
// Make the call
...
}
}
I then catch the thrown exception in the controller to redirect to the error page. I've tested it and this code appears to work fine. The problem is that the method above is underlined (I'm using SpringSource Tool Suite for an IDE) and says
Exception HttpResponseException is not compatible with
throws clause in SearchService.getPersonSearch(String, String)
Does anyone know what might be causing this? Also, might it mean that there is an actual problem or circumstance where this will cause the app to break? Like I said, from what I can tell the throw/redirect is working like a champ, but that error makes me nervous about moving the app to production.
Thanks in advance,
-Mike
I would say that your interface SearchService is not right! what is the signature of the method 'getPersonSearch' in the interface?
its like this:
List<Person> getPersonSearch( String fName, String lName);
or like this:
List<Person> getPersonSearch( String fName, String lName) throws HttpResponseException;
the second one is correct, if you have the first one, thats should be the problem!