package org.zalando.nakadi.annotations.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({
        ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE,
        ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@NotEmpty(message = "Key cannot be empty")
@Pattern(regexp = "^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?[^/]*$",
        message = "Key name should be an optional lowercase domain name with path")
@Pattern(regexp = "^([-.a-z0-9]{0,253}/)?[^/]*$",
        message = "Key prefix cannot be more than 253 characters.")
@Pattern(regexp = "^([-.a-z0-9]+/)?[^/]{0,63}$",
        message = "Key name cannot be more than 63 characters.")
@Pattern(regexp = "^([^/]+/)?[a-zA-Z0-9]([a-zA-Z0-9_.-]*[a-zA-Z0-9])?$",
        message = "Key name should start with letter or digit and end with letter")
@Constraint(validatedBy = {})
public @interface LabelKey {
    String message() default "{org.zalando.nakadi.annotations.validation.LabelKey.message}}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

package org.zalando.nakadi.annotations.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({
        ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE,
        ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@AnnotationKey
@Constraint(validatedBy = {})
public @interface LabelKey {
    String message() default "{org.zalando.nakadi.annotations.validation.LabelKey.message}}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};
}

Reduce the amount of lines

Reduce the amount of lines


package io.car.server.rest.encoding.rdf.linker;

import com.google.inject.Provider;
import com.hp.hpl.jena.rdf.model.Model;
import io.car.server.core.entities.Group;
import io.car.server.core.entities.Measurement;
import io.car.server.rest.encoding.rdf.RDFLinker;
import static io.car.server.rest.encoding.rdf.linker.MeasurementDCTermsLinker.ODBL_URL;
import io.car.server.rest.resources.GroupsResource;
import io.car.server.rest.resources.MeasurementsResource;
import io.car.server.rest.resources.RootResource;
import io.car.server.rest.rights.AccessRights;
import javax.ws.rs.core.UriBuilder;

/**
 *
 * @author Jan Wirwahn
 */
public class GroupDCTermsLinker implements RDFLinker<Group> {

    public static final String ODBL_URL = "http://opendatacommons.org/licenses/odbl/";

    @Override
    public void link(Model m, Group t, AccessRights rights, Provider<UriBuilder> uriBuilder) {
        String uri = uriBuilder.get()
                .path(RootResource.class)
                .path(RootResource.GROUPS)
                .path(GroupsResource.GROUP)
                .build(t.getName()).toASCIIString();

        m.createResource(uri).addProperty(DCTerms.rights, ODBL_URL);
    }
}

package io.car.server.rest.encoding.rdf.linker;

import com.google.inject.Provider;
import com.hp.hpl.jena.rdf.model.Model;
import io.car.server.core.entities.Group;
import io.car.server.rest.encoding.rdf.RDFLinker;
import io.car.server.rest.resources.GroupsResource;
import io.car.server.rest.resources.RootResource;
import io.car.server.rest.rights.AccessRights;
import javax.ws.rs.core.UriBuilder;

/**
 *
 * @author Jan Wirwahn
 */
public class GroupDCTermsLinker implements RDFLinker<Group> {

    public static final String ODBL_URL = "http://opendatacommons.org/licenses/odbl/";

    @Override
    public void link(Model m, Group t, AccessRights rights, Provider<UriBuilder> uriBuilder) {
        String uri = uriBuilder.get()
                .path(RootResource.class)
                .path(RootResource.GROUPS)
                .path(GroupsResource.GROUP)
                .build(t.getName()).toASCIIString();

        m.createResource(uri).addProperty(DCTerms.rights, ODBL_URL);
    }
}

Fix in group DC licence

Fix in group DC licence


/*******************************************************************************
 * Copyright (c) 2006 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.chart.ui.swt.wizard.format.popup.series;

import org.eclipse.birt.chart.model.component.Scale;
import org.eclipse.birt.chart.model.type.DialSeries;
import org.eclipse.birt.chart.ui.swt.composites.TextEditorComposite;
import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext;
import org.eclipse.birt.chart.ui.swt.wizard.format.popup.AbstractScaleSheet;

/**
 *
 */

public class DialScaleSheet extends AbstractScaleSheet
{

	private DialSeries series;

	public DialScaleSheet( String title, ChartWizardContext context,
			DialSeries series )
	{
		super( title, context );
		this.series = series;
	}

	protected Scale getScale( )
	{
		return series.getDial( ).getScale( );
	}

	protected int getValueType( )
	{
		return TextEditorComposite.TYPE_NUMBERIC;
	}

}

/*******************************************************************************
 * Copyright (c) 2006 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *******************************************************************************/

package org.eclipse.birt.chart.ui.swt.wizard.format.popup.series;

import org.eclipse.birt.chart.model.component.Scale;
import org.eclipse.birt.chart.model.type.DialSeries;
import org.eclipse.birt.chart.ui.swt.composites.TextEditorComposite;
import org.eclipse.birt.chart.ui.swt.wizard.ChartWizardContext;
import org.eclipse.birt.chart.ui.swt.wizard.format.popup.AbstractScaleSheet;

/**
 *
 */

public class DialScaleSheet extends AbstractScaleSheet
{

	private DialSeries series;

	public DialScaleSheet( String title, ChartWizardContext context,
			DialSeries series )
	{
		super( title, context );
		this.series = series;
	}

	protected Scale getScale( )
	{
		return series.getDial( ).getScale( );
	}

	protected int getValueType( )
	{
		return TextEditorComposite.TYPE_NUMBERIC;
	}

	protected void setState( )
	{
		super.setState( );
		// Hide invalid attributes.
		btnShowOutside.setVisible( false );
	}

}

Remove UI of ShowOutside for Dial scale

Remove UI of ShowOutside for Dial scale


package com.codenvy.ide.ext.datasource.client.sqllauncher;

import com.codenvy.ide.api.editor.EditorPartPresenter;
import com.codenvy.ide.api.editor.EditorProvider;
import com.codenvy.ide.api.notification.NotificationManager;
import com.codenvy.ide.api.preferences.PreferencesManager;
import com.codenvy.ide.dto.DtoFactory;
import com.codenvy.ide.ext.datasource.client.DatasourceClientService;
import com.codenvy.ide.ext.datasource.client.DatasourceManager;
import com.codenvy.ide.ext.datasource.client.sqleditor.SqlEditorProvider;
import com.google.inject.Inject;
import com.google.web.bindery.event.shared.EventBus;

public class SqlLauncherEditorProvider implements EditorProvider {

    private final NotificationManager   notificationManager;

    private final SqlEditorProvider     sqlEditorProvider;

    private SqlRequestLauncherConstants constants;

    private PreferencesManager          preferencesManager;

    private DatasourceManager           datasourceManager;

    private EventBus                    eventBus;

    private DatasourceClientService     service;

    private DtoFactory                  dtoFactory;

    private SqlRequestLauncherFactory   sqlRequestLauncherFactory;

    @Inject
    public SqlLauncherEditorProvider(final NotificationManager notificationManager,
                                     final SqlEditorProvider sqlEditorProvider,
                                     final SqlRequestLauncherConstants constants,
                                     final PreferencesManager preferencesManager,
                                     final DatasourceManager datasourceManager,
                                     final EventBus eventBus,
                                     final DatasourceClientService service,
                                     final DtoFactory dtoFactory,
                                     final SqlRequestLauncherFactory sqlRequestLauncherFactory) {
        this.notificationManager = notificationManager;
        this.sqlEditorProvider = sqlEditorProvider;
        this.constants = constants;
        this.preferencesManager = preferencesManager;
        this.datasourceManager = datasourceManager;
        this.eventBus = eventBus;
        this.service = service;
        this.dtoFactory = dtoFactory;
        this.sqlRequestLauncherFactory = sqlRequestLauncherFactory;
    }

    @Override
    public EditorPartPresenter getEditor() {
        return new SqlRequestLauncherAdapter(sqlRequestLauncherFactory.createSqlRequestLauncherView(),
                                             constants,
                                             preferencesManager,
                                             sqlEditorProvider,
                                             service,
                                             notificationManager,
                                             datasourceManager,
                                             eventBus,
                                             dtoFactory);

    }
}

package com.codenvy.ide.ext.datasource.client.sqllauncher;

import com.codenvy.ide.api.editor.EditorPartPresenter;
import com.codenvy.ide.api.editor.EditorProvider;
import com.codenvy.ide.util.loging.Log;
import com.google.inject.Inject;

public class SqlLauncherEditorProvider implements EditorProvider {

    private SqlRequestLauncherFactory sqlRequestLauncherFactory;

    @Inject
    public SqlLauncherEditorProvider(final SqlRequestLauncherFactory sqlRequestLauncherFactory) {
        this.sqlRequestLauncherFactory = sqlRequestLauncherFactory;
    }

    @Override
    public EditorPartPresenter getEditor() {
        Log.info(SqlLauncherEditorProvider.class, "New instance of SQL launcher editor requested.");
        return sqlRequestLauncherFactory.createSqlRequestLauncherPresenter();
    }
}

Simplify the SQL launcher editor provider


/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.karaf.cellar.shell.group;

import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;

@Command(scope = "cluster", name = "group-create", description = "Create a cluster group.")
public class GroupCreateCommand extends GroupSupport {

    @Argument(index = 0, name = "group", description = "The cluster group name.", required = false, multiValued = false)
    String group;

    @Override
    protected Object doExecute() throws Exception {
        return groupManager.createGroup(group);
    }

}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.karaf.cellar.shell.group;

import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;

@Command(scope = "cluster", name = "group-create", description = "Create a cluster group.")
public class GroupCreateCommand extends GroupSupport {

    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
    String group;

    @Override
    protected Object doExecute() throws Exception {
        return groupManager.createGroup(group);
    }

}

[KARAF-1313] Set group argument as required in cluster:group-create command

git-svn-id: 23a5554d8b20ee894ad801d0a5fe136f33ef549e@1330248 13f79535-47bb-0310-9956-ffa450edef68


package org.techern.infinitewater.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

/**
 * A {@link Block} for infinitely spreading water
 *
 * @since 1.0.0
 */
public class BlockInfinitelySpreadingWater extends Block {

    /**
     * Creates a new {@link BlockInfinitelySpreadingWater}
     *
     * @since 1.0.0
     */
    public BlockInfinitelySpreadingWater() {
        super(Material.WATER);

        this.setUnlocalizedName("infinitely_spreading_water");
        this.setRegistryName("infinitely_spreading_water");
        this.setBlockUnbreakable();
    }
}

package org.techern.infinitewater.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;

/**
 * A {@link Block} for infinitely spreading water
 *
 * @since 1.0.0
 */
public class BlockInfinitelySpreadingWater extends Block {

    /**
     * Creates a new {@link BlockInfinitelySpreadingWater}
     *
     * @since 1.0.0
     */
    public BlockInfinitelySpreadingWater() {
        super(Material.WATER);

        this.setCreativeTab(CreativeTabs.MISC);
        this.setUnlocalizedName("infinitely_spreading_water");
        this.setRegistryName("infinitely_spreading_water");
        this.setBlockUnbreakable();
    }
}

Add to Misc creative tab

Add to Misc creative tab


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.prelude.fastsearch;

import com.yahoo.data.access.Inspector;
import com.yahoo.data.access.Type;
import com.yahoo.prelude.hitfield.XMLString;
import com.yahoo.search.result.PositionsData;

/**
 * Class converting data (historically XML-encoded) from a document summary field.
 * This has only been used to represent geographical positions.
 * @author Steinar Knutsen
 */
public class XMLField extends DocsumField {

    public XMLField(String name) {
        super(name);
    }

    private Object convert(String value) {
        return new XMLString(value);
    }

    @Override
    public String toString() {
        return "field " + getName() + " type XMLString";
    }

    @Override
    public Object convert(Inspector value) {
        /* In Vespa 6 the backend will send an XML-formatted string to represent
         * positions data.  This will change in next version to sending an object
         * or an array of objects instead, suitable for the PositionsData class.
         */
        if (value.type() == Type.OBJECT || value.type() == Type.ARRAY) {
            return new PositionsData(value);
        }
        return convert(value.asString(""));
    }

}

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.prelude.fastsearch;

import com.yahoo.data.access.Inspector;
import com.yahoo.data.access.Type;
import com.yahoo.prelude.hitfield.XMLString;
import com.yahoo.search.result.PositionsData;

/**
 * Class converting data (historically XML-encoded) from a document summary field.
 * This has only been used to represent geographical positions.
 * @author Steinar Knutsen
 */
public class XMLField extends DocsumField {

    public XMLField(String name) {
        super(name);
    }

    private Object convert(String value) {
        return new XMLString(value);
    }

    @Override
    public String toString() {
        return "field " + getName() + " type XMLString";
    }

    @Override
    public Object convert(Inspector value) {
        if (value.type() == Type.OBJECT || value.type() == Type.ARRAY) {
            return new PositionsData(value);
        }
        return convert(value.asString(""));
    }

}

Remove comment looking forward to Vespa 6.


// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component;

/**
 * A {@link BindingPattern} which is implicitly constructed by the model, e.g for built-in handlers and filter chains.
 *
 * @author bjorncs
 */
public class SystemBindingPattern extends BindingPattern {

    private SystemBindingPattern(String scheme, String host, String port, String path) { super(scheme, host, port, path); }
    private SystemBindingPattern(String binding) { super(binding); }

    public static SystemBindingPattern fromHttpPath(String path) { return new SystemBindingPattern("http", "*", null, path);}
    public static SystemBindingPattern fromPattern(String binding) { return new SystemBindingPattern(binding);}

    @Override
    public String toString() {
        return "SystemBindingPattern{" +
                "scheme='" + scheme() + '\'' +
                ", host='" + host() + '\'' +
                ", port='" + port().orElse(null) + '\'' +
                ", path='" + path() + '\'' +
                '}';
    }
}

// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.component;

/**
 * A {@link BindingPattern} which is implicitly constructed by the model, e.g for built-in handlers and filter chains.
 *
 * @author bjorncs
 */
public class SystemBindingPattern extends BindingPattern {

    private SystemBindingPattern(String scheme, String host, String port, String path) { super(scheme, host, port, path); }
    private SystemBindingPattern(String binding) { super(binding); }

    public static SystemBindingPattern fromHttpPath(String path) { return new SystemBindingPattern("http", "*", null, path);}
    public static SystemBindingPattern fromPattern(String binding) { return new SystemBindingPattern(binding);}
    public static SystemBindingPattern fromPortAndPath(String port, String path) { return new SystemBindingPattern("http", "*", port, path); }

    @Override
    public String toString() {
        return "SystemBindingPattern{" +
                "scheme='" + scheme() + '\'' +
                ", host='" + host() + '\'' +
                ", port='" + port().orElse(null) + '\'' +
                ", path='" + path() + '\'' +
                '}';
    }
}

Add static builder taking port and path

Add static builder taking port and path


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.vfs2.provider.sftp;

import org.apache.commons.vfs2.provider.FileNameParser;
import org.apache.commons.vfs2.provider.URLFileNameParser;

/**
 * Implementation for sftp. set default port to 22.
 */
public class SftpFileNameParser extends URLFileNameParser
{
    private static final SftpFileNameParser INSTANCE = new SftpFileNameParser();

    public SftpFileNameParser()
    {
        super(22);
    }

    public static FileNameParser getInstance()
    {
        return INSTANCE;
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.commons.vfs2.provider.sftp;

import org.apache.commons.vfs2.provider.FileNameParser;
import org.apache.commons.vfs2.provider.URLFileNameParser;

/**
 * Implementation for sftp. set default port to 22.
 */
public class SftpFileNameParser extends URLFileNameParser
{
    private static final int DEFAULT_PORT = 22;

    private static final SftpFileNameParser INSTANCE = new SftpFileNameParser();

    public SftpFileNameParser()
    {
        super(DEFAULT_PORT);
    }

    public static FileNameParser getInstance()
    {
        return INSTANCE;
    }
}

Refactor magic port number into constant.

git-svn-id: c455d203a03ec41bf444183aad31e7cce55db786@1349874 13f79535-47bb-0310-9956-ffa450edef68


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
@Version("3.1.0")
package org.apache.jackrabbit.oak.spi.mount;

import org.osgi.annotation.versioning.Version;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
@Version("3.2.0")
package org.apache.jackrabbit.oak.spi.mount;

import org.osgi.annotation.versioning.Version;

Make the MountInfo constructor public

OAK-7582: Make the MountInfo constructor public

git-svn-id: 67138be12999c61558c3dd34328380c8e4523e73@1834290 13f79535-47bb-0310-9956-ffa450edef68


/*
 * Copyright 2014-2021 Real Logic Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.aeron.log;

import io.aeron.test.Tests;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
 * JUnit extension to start and reset the CollectingEventLogReaderAgent.
 */
public class EventLogExtension implements BeforeEachCallback, AfterEachCallback
{
    /**
     * {@inheritDoc}
     */
    public void beforeEach(final ExtensionContext context)
    {
        final String className = context.getTestClass().map(Class::getSimpleName).orElse("<UNKNOWN>");
        final String methodName = context.getTestClass().map(Class::getSimpleName).orElse(context.getDisplayName());
        Tests.startLogCollecting("TEST: " + className + "." + methodName);
    }

    /**
     * {@inheritDoc}
     */
    public void afterEach(final ExtensionContext context)
    {
        Tests.resetLogCollecting();
    }
}

/*
 * Copyright 2014-2021 Real Logic Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.aeron.log;

import io.aeron.test.Tests;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.lang.reflect.Method;

/**
 * JUnit extension to start and reset the CollectingEventLogReaderAgent.
 */
public class EventLogExtension implements BeforeEachCallback, AfterEachCallback
{
    /**
     * {@inheritDoc}
     */
    public void beforeEach(final ExtensionContext context)
    {
        final String className = context.getTestClass().map(Class::getSimpleName).orElse("<UNKNOWN>");
        final String methodName = context.getTestMethod().map(Method::getName).orElse(context.getDisplayName());
        Tests.startLogCollecting("TEST: " + className + "." + methodName);
    }

    /**
     * {@inheritDoc}
     */
    public void afterEach(final ExtensionContext context)
    {
        Tests.resetLogCollecting();
    }
}

Fix name recorded in test event log.

[Java] Fix name recorded in test event log.


package io.fluxcapacitor.javaclient.common;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.fluxcapacitor.common.MessageType;
import io.fluxcapacitor.common.api.Metadata;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;

@Value
@AllArgsConstructor
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public class Message {
    public static IdentityProvider identityProvider = new UuidFactory();

    @Wither
    Object payload;
    Metadata metadata;
    MessageType messageType;
    String messageId;

    public Message(Object payload, MessageType messageType) {
        this(payload, Metadata.empty(), messageType, identityProvider.nextId());
    }

    public Message(Object payload, Metadata metadata, MessageType messageType) {
        this(payload, metadata, messageType, identityProvider.nextId());
    }

    @SuppressWarnings("unchecked")
    public <R> R getPayload() {
        return (R) payload;
    }
}

package io.fluxcapacitor.javaclient.common;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.fluxcapacitor.common.MessageType;
import io.fluxcapacitor.common.api.Metadata;
import lombok.AllArgsConstructor;
import lombok.Value;
import lombok.experimental.Wither;

@Value
@AllArgsConstructor
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public class Message {
    public static IdentityProvider identityProvider = new UuidFactory();

    @Wither
    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
    Object payload;
    Metadata metadata;
    MessageType messageType;
    String messageId;

    public Message(Object payload, MessageType messageType) {
        this(payload, Metadata.empty(), messageType, identityProvider.nextId());
    }

    public Message(Object payload, Metadata metadata, MessageType messageType) {
        this(payload, metadata, messageType, identityProvider.nextId());
    }

    @SuppressWarnings("unchecked")
    public <R> R getPayload() {
        return (R) payload;
    }
}

Add Jackson type information to message payload


package org.spoofax.modelware.emf;

/**
 * @author Oskar van Rest
 */
import java.util.ArrayList;
import java.util.Collection;

public class LanguageRegistry {

	private static LanguageRegistry instance = new LanguageRegistry();

	private Collection<Language> languages = new ArrayList<Language>();

	private LanguageRegistry() {
	}

	public static LanguageRegistry getInstance() {
		return instance;
	}

	public void add(Language language) {
		languages.add(language);
	}

	public Language get(String fileExtension) {
		for (Language language : languages) {
			if (language.getTextFileExtension().equals(fileExtension) || language.getDiagramFileExtension().equals(fileExtension)) {
				return language;
			}
		}

		// fallback: some user may choose a file extension like .fml.diagram, in which case the language can be obtained using extensions .fml.diagram and .diagram (the actual file extension).
		for (Language language : languages) {
			if (language.getTextFileExtension().endsWith(fileExtension) || language.getDiagramFileExtension().endsWith(fileExtension)) {
				return language;
			}
		}
		return null;
	}
}

package org.spoofax.modelware.emf;

/**
 * @author Oskar van Rest
 */
import java.util.ArrayList;
import java.util.Collection;

public class LanguageRegistry {

	private static LanguageRegistry instance = new LanguageRegistry();

	private Collection<Language> languages = new ArrayList<Language>();

	private LanguageRegistry() {
	}

	public static LanguageRegistry getInstance() {
		return instance;
	}

	public void add(Language language) {
		languages.add(language);
	}

	public Language get(String fileExtension) {
		for (Language language : languages) {
			if (language.getTextFileExtension().equals(fileExtension) || language.getDiagramFileExtension().equals(fileExtension)) {
				return language;
			}
		}
		return null;
	}
}

Revert "support for file extensions with dots (.) in them"

This reverts commit 4439ab932535897adc93039a5b212ea21ef399df.


package com.yatatsu.autobundle;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.SOURCE)
public @interface AutoBundleField {
    boolean required() default true;
    String key() default "";
    Class<? extends AutoBundleConverter> converter() default DefaultAutoBundleConverter.class;
}

package com.yatatsu.autobundle;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.CLASS)
public @interface AutoBundleField {
    boolean required() default true;
    String key() default "";
    Class<? extends AutoBundleConverter> converter() default DefaultAutoBundleConverter.class;
}

Change retention policy of annotation

Change retention policy of annotation


package de.idrinth.waraddonclient.model;

import java.util.ArrayList;
import java.util.HashMap;

public class CaseInsensitiveHashMap<T> extends HashMap<String, T> {

    private ArrayList<String> keys = new ArrayList<>();

    @Override
    public T put(String key, T value) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return super.put(k, value);
            }
        }
        keys.add(key);
        return super.put(key, value);
    }
    public T get(String key) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return super.get(k);
            }
        }
        return super.get(key);
    }
    public boolean containsKey(String key) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return true;
            }
        }
        return false;
    }
}

package de.idrinth.waraddonclient.model;

import java.util.ArrayList;
import java.util.HashMap;

public class CaseInsensitiveHashMap<T> extends HashMap<String, T> {

    private final ArrayList<String> keys = new ArrayList<>();

    @Override
    public T put(String key, T value) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return super.put(k, value);
            }
        }
        keys.add(key);
        return super.put(key, value);
    }
    public T get(String key) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return super.get(k);
            }
        }
        return super.get(key);
    }
    public boolean containsKey(String key) {
        for (String k : keys) {
            if (k.equalsIgnoreCase(key)) {
                return true;
            }
        }
        return false;
    }
}

Add final modifier to field

Add final modifier to field


package org.synyx.urlaubsverwaltung.application;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties("uv.application")
public class ApplicationProperties {

    /**
     * Checks remind date about waiting applications by default every day at 07:00 am
     */
    private String reminderNotificationCron = "0 0 7 * * *";

    public String getReminderNotificationCron() {
        return reminderNotificationCron;
    }

    public void setReminderNotificationCron(String reminderNotificationCron) {
        this.reminderNotificationCron = reminderNotificationCron;
    }
}

package org.synyx.urlaubsverwaltung.application;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotEmpty;

@Component
@ConfigurationProperties("uv.application")
@Validated
public class ApplicationProperties {

    /**
     * Checks remind date about waiting applications by default every day at 07:00 am
     */
    @NotEmpty
    private String reminderNotificationCron = "0 0 7 * * *";

    public String getReminderNotificationCron() {
        return reminderNotificationCron;
    }

    public void setReminderNotificationCron(String reminderNotificationCron) {
        this.reminderNotificationCron = reminderNotificationCron;
    }
}

Add bean validation for uv.application.reminderNotificationCron


package org.gbif.registry.cli.doiupdater;

import org.gbif.common.messaging.MessageListener;
import org.gbif.registry.cli.common.CommonBuilder;
import org.gbif.registry.persistence.guice.RegistryMyBatisModule;
import org.gbif.registry.persistence.mapper.DoiMapper;

import com.google.common.util.concurrent.AbstractIdleService;
import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * A CLI service that starts and stops a listener of DoiUpdate messages. Must always be only one thread - multiple
 * will introduce a possible race (e.g. delete before create).
 */
public class DoiUpdaterService extends AbstractIdleService {

  private final DoiUpdaterConfiguration config;

  private MessageListener listener;

  public DoiUpdaterService(DoiUpdaterConfiguration config) {
    this.config = config;
  }

  @Override
  protected void startUp() throws Exception {
    config.ganglia.start();

    Injector inj = Guice.createInjector(
      new RegistryMyBatisModule(config.registry.toRegistryProperties()));

    listener = new MessageListener(config.messaging.getConnectionParameters());
    listener.listen(config.queueName, 1,
      new DoiUpdateListener(CommonBuilder.createRestJsonApiDataCiteService(config.datacite), inj.getInstance(DoiMapper.class), config.timeToRetryInMs));
  }

  @Override
  protected void shutDown() throws Exception {
    if (listener != null) {
      listener.close();
    }
  }
}

package org.gbif.registry.cli.doiupdater;

import org.gbif.common.messaging.MessageListener;
import org.gbif.registry.cli.common.CommonBuilder;
import org.gbif.registry.persistence.guice.RegistryMyBatisModule;
import org.gbif.registry.persistence.mapper.DoiMapper;

import com.google.common.util.concurrent.AbstractIdleService;
import com.google.inject.Guice;
import com.google.inject.Injector;

/**
 * A CLI service that starts and stops a listener of DoiUpdate messages. Must always be only one thread - multiple
 * will introduce a possible race (e.g. delete before create).
 */
public class DoiUpdaterService extends AbstractIdleService {

  private final DoiUpdaterConfiguration config;

  private MessageListener listener;

  public DoiUpdaterService(DoiUpdaterConfiguration config) {
    this.config = config;
  }

  @Override
  protected void startUp() throws Exception {
    config.ganglia.start();

    Injector inj = Guice.createInjector(
      new RegistryMyBatisModule(config.registry.toRegistryProperties()));

    listener = new MessageListener(config.messaging.getConnectionParameters(), 1);
    listener.listen(config.queueName, 1,
      new DoiUpdateListener(CommonBuilder.createRestJsonApiDataCiteService(config.datacite), inj.getInstance(DoiMapper.class), config.timeToRetryInMs));
  }

  @Override
  protected void shutDown() throws Exception {
    if (listener != null) {
      listener.close();
    }
  }
}

Set message prefetch to 1 for DOI updater.

Can help with debugging / service recovery etc.


package info.u_team.u_team_test.init;

import info.u_team.u_team_test.entity.TestLiving;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;

public class TestSpawnPlacementRegistries {

	private static void setup(FMLCommonSetupEvent event) {
		event.enqueueWork(() -> {
			SpawnPlacements.register(TestEntityTypes.TEST_LIVING.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, TestLiving::checkTestLivingSpawnRules);
		});
	}

	public static void registerMod(IEventBus bus) {
		bus.addListener(TestSpawnPlacementRegistries::setup);
	}

}

package info.u_team.u_team_test.init;

import info.u_team.u_team_test.entity.TestLiving;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraftforge.event.entity.SpawnPlacementRegisterEvent;
import net.minecraftforge.event.entity.SpawnPlacementRegisterEvent.Operation;
import net.minecraftforge.eventbus.api.IEventBus;

public class TestSpawnPlacementRegistries {

	private static void register(SpawnPlacementRegisterEvent event) {
		event.register(TestEntityTypes.TEST_LIVING.get(), SpawnPlacements.Type.ON_GROUND, Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, TestLiving::checkTestLivingSpawnRules, Operation.OR);
	}

	public static void registerMod(IEventBus bus) {
		bus.addListener(TestSpawnPlacementRegistries::register);
	}

}

Use event in test mod for spawn placement registry


package com.link_intersystems.gitdirstat.domain;

import java.io.IOException;
import java.util.Collection;

public class PathDeletionIndexFilter implements IndexFilter {

	private Collection<String> pathsToDelete;

	public PathDeletionIndexFilter(Collection<String> pathsToDelete) {
		this.pathsToDelete = pathsToDelete;
	}

	@Override
	public void apply(CommitUpdate commitUpdate) throws IOException {
		TreeUpdate treeUpdate = commitUpdate.getTreeUpdate();
		while (treeUpdate.hasNext()) {
			TreeFileUpdate fileUpdate = treeUpdate.next();
			String path = fileUpdate.getPath();
			if (pathsToDelete.contains(path)) {
				fileUpdate.delete();
			}
		}
	}
}

package com.link_intersystems.gitdirstat.domain;

import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;

public class PathDeletionIndexFilter implements IndexFilter {

	private Collection<String> pathsToDelete;

	public PathDeletionIndexFilter(Collection<String> pathsToDelete) {
		this.pathsToDelete = pathsToDelete;
	}

	@Override
	public void apply(CommitUpdate commitUpdate) throws IOException {
		TreeUpdate treeUpdate = commitUpdate.getTreeUpdate();
		Collection<String> actualPathsToDelete = new HashSet<String>(
				pathsToDelete);
		while (treeUpdate.hasNext()) {
			TreeFileUpdate fileUpdate = treeUpdate.next();
			String path = fileUpdate.getPath();
			if (actualPathsToDelete.remove(path)) {
				fileUpdate.delete();
			}
			if (actualPathsToDelete.isEmpty()) {
				break;
			}
		}
	}
}

Stop iterating tree if all index filter paths are deleted


package com.github.games647.fastlogin.bukkit;

import java.util.List;

import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderHook;

import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;

public class PremiumPlaceholder extends PlaceholderHook {

    private final FastLoginBukkit plugin;

    public PremiumPlaceholder(FastLoginBukkit plugin) {
        this.plugin = plugin;
    }

    @Override
    public String onPlaceholderRequest(Player player, String variable) {
        if (player != null && "fastlogin_status".contains(variable)) {
            List<MetadataValue> metadata = player.getMetadata(plugin.getName());
            if (metadata == null) {
                return "unknown";
            }

            if (metadata.isEmpty()) {
                return "cracked";
            } else {
                return "premium";
            }
        }

        return "";
    }

    public static void register(FastLoginBukkit plugin) {
        PlaceholderAPI.registerPlaceholderHook(plugin, new PremiumPlaceholder(plugin));
    }
}

package com.github.games647.fastlogin.bukkit;

import java.util.stream.Collectors;

import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;

import org.bukkit.entity.Player;

public class PremiumPlaceholder extends PlaceholderExpansion {

    private static final String PLACEHOLDER_VARIABLE = "fastlogin_status";

    private final FastLoginBukkit plugin;

    public PremiumPlaceholder(FastLoginBukkit plugin) {
        this.plugin = plugin;
    }

    public static void register(FastLoginBukkit plugin) {
        PremiumPlaceholder placeholderHook = new PremiumPlaceholder(plugin);
        PlaceholderAPI.registerPlaceholderHook(PLACEHOLDER_VARIABLE, placeholderHook);
    }

    @Override
    public String onPlaceholderRequest(Player player, String variable) {
        if (player != null && PLACEHOLDER_VARIABLE.equals(variable)) {
            return plugin.getStatus(player.getUniqueId()).name();
        }

        return "";
    }

    @Override
    public String getIdentifier() {
        return PLACEHOLDER_VARIABLE;
    }

    @Override
    public String getPlugin() {
        return plugin.getName();
    }

    @Override
    public String getAuthor() {
        return plugin.getDescription().getAuthors().stream().collect(Collectors.joining(", "));
    }

    @Override
    public String getVersion() {
        return plugin.getName();
    }
}

Migrate to PlaceholderExpansion from PlaceholderAPI


package se.jiderhamn.classloader.leak.prevention.cleanup;

import java.security.NoSuchAlgorithmException;
import java.security.Provider;

/**
 * Test that the leak caused by {@link javax.crypto.JceSecurity} is cleared.
 * Thanks to Paul Kiman for the report.
 * @author Mattias Jiderhamn
 */
public class JceSecurityCleanUpTest extends ClassLoaderPreMortemCleanUpTestBase<JceSecurityCleanUp> {
  @Override
  protected void triggerLeak() throws Exception {
    try {
      // Alternative classes: KeyAgreement, KeyGenerator, ExemptionMechanism
      MyProvider myProvider = new MyProvider("foo", 1.0, "bar");
      javax.crypto.Mac.getInstance("baz", myProvider);
    }
    catch (SecurityException e) { // CS:IGNORE
    }
    catch (NoSuchAlgorithmException e) {
      // Custom providers seem to work different in Java 11, this still triggers the leak, even if we get this exception
    }
  }

  /** Custom {@link Provider}, to be put in {@link javax.crypto.JceSecurity} caches */
  public static class MyProvider extends Provider {
    public MyProvider(String name, double version, String info) {
      super(name, version, info);
    }

    @Override
    public synchronized Service getService(String type, String algorithm) {
      return new Service(this, "type", "algorithm", "className", null, null);
    }
  }
}

package se.jiderhamn.classloader.leak.prevention.cleanup;

import java.security.NoSuchAlgorithmException;
import java.security.Provider;

/**
 * Test that the leak caused by {@link javax.crypto.JceSecurity} is cleared.
 * Thanks to Paul Kiman for the report.
 * @author Mattias Jiderhamn
 */
public class JceSecurityCleanUpTest extends ClassLoaderPreMortemCleanUpTestBase<JceSecurityCleanUp> {
  @Override
  protected void triggerLeak() throws Exception {
    try {
      // Alternative classes: KeyAgreement, KeyGenerator, ExemptionMechanism
      MyProvider myProvider = new MyProvider("foo", 1.0, "bar");
      javax.crypto.Mac.getInstance("baz", myProvider);
    }
    catch (SecurityException | NoSuchAlgorithmException e) { // CS:IGNORE
      // Leak is triggered despite an exception being thrown
    }
  }

  /** Custom {@link Provider}, to be put in {@link javax.crypto.JceSecurity} caches */
  public static class MyProvider extends Provider {
    public MyProvider(String name, double version, String info) {
      super(name, version, info);
    }

    @Override
    public synchronized Service getService(String type, String algorithm) {
      return new Service(this, "type", "algorithm", "className", null, null);
    }
  }
}

Move exceptions in one catch expression

JceSecurityCleanupTest: Move exceptions in one catch expression


package org.wildfly.swarm.swagger.runtime;

import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.Archive;
import org.wildfly.swarm.container.JARArchive;
import org.wildfly.swarm.container.runtime.AbstractServerConfiguration;
import org.wildfly.swarm.container.runtime.Configuration;
import org.wildfly.swarm.jaxrs.JAXRSArchive;
import org.wildfly.swarm.swagger.SwaggerFraction;

import java.util.Collections;
import java.util.List;

/**
 * @author Lance Ball
 */
@Configuration
public class SwaggerConfiguration extends AbstractServerConfiguration<SwaggerFraction> {

    public SwaggerConfiguration() {
        super(SwaggerFraction.class);
    }

    @Override
    public SwaggerFraction defaultFraction() {
        return new SwaggerFraction();
    }

    @Override
    public void prepareArchive(Archive<?> a) {
        JAXRSArchive deployment = a.as(JAXRSArchive.class);
        JARArchive archive = a.as(JARArchive.class);
        try {
            archive.addModule("io.swagger");
            deployment.addResource(io.swagger.jaxrs.listing.ApiListingResource.class);
            deployment.addResource(io.swagger.jaxrs.listing.SwaggerSerializers.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public List<ModelNode> getList(SwaggerFraction fraction) throws Exception {
        return Collections.emptyList();
    }
}

package org.wildfly.swarm.swagger.runtime;

import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.Archive;
import org.wildfly.swarm.container.JARArchive;
import org.wildfly.swarm.container.runtime.AbstractServerConfiguration;
import org.wildfly.swarm.jaxrs.JAXRSArchive;
import org.wildfly.swarm.swagger.SwaggerFraction;

import java.util.Collections;
import java.util.List;

/**
 * @author Lance Ball
 */
public class SwaggerConfiguration extends AbstractServerConfiguration<SwaggerFraction> {

    public SwaggerConfiguration() {
        super(SwaggerFraction.class);
    }

    @Override
    public SwaggerFraction defaultFraction() {
        return new SwaggerFraction();
    }

    @Override
    public void prepareArchive(Archive<?> a) {
        JAXRSArchive deployment = a.as(JAXRSArchive.class);
        JARArchive archive = a.as(JARArchive.class);
        try {
            archive.addModule("io.swagger");
            deployment.addResource(io.swagger.jaxrs.listing.ApiListingResource.class);
            deployment.addResource(io.swagger.jaxrs.listing.SwaggerSerializers.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public List<ModelNode> getList(SwaggerFraction fraction) throws Exception {
        return Collections.emptyList();
    }
}

Remove the need for @Configuration annotation. Simplify!


/*
 * Copyright 2017 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.terasology.rendering;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class FontUnderlineTest {

    private static final char START_UNDERLINE = 0xF001;
    private static final char END_UNDERLINE = 0xF002;

    @Test
    public void testStartUnderline() {
        assertTrue(FontUnderline.isValid(START_UNDERLINE));
    }

    @Test
    public void testEndUnderline() {
        assertTrue(FontUnderline.isValid(END_UNDERLINE));
    }

    @Test
    public void testInvalidUnderline() {
        char invalidUnderline = 0xF003;
        assertFalse(FontUnderline.isValid(invalidUnderline));
    }

    @Test
    public void testMarkUnderlined() {
        String testString = "string";
        assertTrue(FontUnderline.markUnderlined(testString).equals(START_UNDERLINE + testString + END_UNDERLINE));
    }
}

/*
 * Copyright 2017 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.terasology.rendering;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class FontUnderlineTest {

    private static final char START_UNDERLINE = 0xF001;
    private static final char END_UNDERLINE = 0xF002;

    @Test
    public void testStartUnderline() {
        assertTrue(FontUnderline.isValid(START_UNDERLINE));
    }

    @Test
    public void testEndUnderline() {
        assertTrue(FontUnderline.isValid(END_UNDERLINE));
    }

    @Test
    public void testInvalidUnderline() {
        char invalidUnderline = 0xF003;
        assertFalse(FontUnderline.isValid(invalidUnderline));
    }

    @Test
    public void testMarkUnderlined() {
        String testString = "string";
        assertTrue(FontUnderline.markUnderlined(testString).equals(START_UNDERLINE + testString + END_UNDERLINE));
    }
}

Reformat tests to remove tabs

Reformat tests to remove tabs


package com.github.sormuras.bach.internal;

import java.lang.module.ModuleFinder;
import java.util.List;
import java.util.Set;

/** Module-related utilities. */
public class Modules {

  public static ModuleLayer layer(ModuleFinder finder) {
    var boot = ModuleLayer.boot();
    var configuration = boot.configuration().resolveAndBind(ModuleFinder.of(), finder, Set.of());
    var parent = Modules.class.getClassLoader();
    var controller = ModuleLayer.defineModulesWithOneLoader(configuration, List.of(boot), parent);
    return controller.layer();
  }

  /** Hide default constructor. */
  private Modules() {}
}

package com.github.sormuras.bach.internal;

import java.lang.module.ModuleDescriptor;
import java.lang.module.ModuleDescriptor.Requires;
import java.lang.module.ModuleFinder;
import java.lang.module.ModuleReference;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/** Module-related utilities. */
public class Modules {

  public static Set<String> declared(ModuleFinder finder) {
    return declared(finder.findAll().stream().map(ModuleReference::descriptor));
  }

  public static Set<String> declared(Stream<ModuleDescriptor> descriptors) {
    return descriptors.map(ModuleDescriptor::name).collect(Collectors.toCollection(TreeSet::new));
  }

  public static Set<String> required(ModuleFinder finder) {
    return required(finder.findAll().stream().map(ModuleReference::descriptor));
  }

  public static Set<String> required(Stream<ModuleDescriptor> descriptors) {
    return descriptors
        .map(ModuleDescriptor::requires)
        .flatMap(Set::stream)
        .filter(requires -> !requires.modifiers().contains(Requires.Modifier.MANDATED))
        .filter(requires -> !requires.modifiers().contains(Requires.Modifier.SYNTHETIC))
        .map(Requires::name)
        .collect(Collectors.toCollection(TreeSet::new));
  }

  public static ModuleLayer layer(ModuleFinder finder) {
    var boot = ModuleLayer.boot();
    var configuration = boot.configuration().resolveAndBind(ModuleFinder.of(), finder, Set.of());
    var parent = Modules.class.getClassLoader();
    var controller = ModuleLayer.defineModulesWithOneLoader(configuration, List.of(boot), parent);
    return controller.layer();
  }

  /** Hide default constructor. */
  private Modules() {}
}

Extend module-related utilities with declared and required methods


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.sis.internal.book;

/**
 * Localized resources, for internal usage only.
 *
 * @author  Martin Desruisseaux (Geomatys)
 * @since   0.7
 * @version 0.7
 */
public final class Resources_fr extends Resources {
    @Override
    protected Object[][] getContents() {
        final Object[][] resources = super.getContents();
        resources[0][1] = "Chapitre suivant";
        resources[1][1] = "Chapitre précédent";
        resources[2][1] = "Dans ce chapitre:";
        return resources;
    }
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.sis.internal.book;

/**
 * Localized resources, for internal usage only.
 *
 * @author  Martin Desruisseaux (Geomatys)
 * @since   0.7
 * @version 0.7
 */
public final class Resources_fr extends Resources {
    @Override
    protected Object[][] getContents() {
        final Object[][] resources = super.getContents();
        resources[0][1] = "Chapitre précédent";
        resources[1][1] = "Chapitre suivant";
        resources[2][1] = "Dans ce chapitre:";
        return resources;
    }
}

Fix wrong French resources for the developer guide.

git-svn-id: bd781a9493159d57baabeab2b59de614917f0f5c@1713160 13f79535-47bb-0310-9956-ffa450edef68


/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.tests.hive;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.prestosql.tempto.ProductTest;

import static com.google.common.base.Preconditions.checkState;

public class HiveProductTest
        extends ProductTest
{
    @Inject
    @Named("databases.hive.major_version")
    private int hiveVersionMajor;

    protected int getHiveVersionMajor()
    {
        checkState(hiveVersionMajor > 0, "hiveVersionMajor not set");
        return hiveVersionMajor;
    }
}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.tests.hive;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.prestosql.tempto.ProductTest;

import java.sql.SQLException;

import static com.google.common.base.Preconditions.checkState;
import static io.prestosql.tests.utils.QueryExecutors.onHive;

public class HiveProductTest
        extends ProductTest
{
    @Inject
    @Named("databases.hive.major_version")
    private int hiveVersionMajor;
    private boolean hiveVersionMajorVerified;

    protected int getHiveVersionMajor()
    {
        checkState(hiveVersionMajor > 0, "hiveVersionMajor not set");
        if (!hiveVersionMajorVerified) {
            int detected = detectHiveVersionMajor();
            checkState(hiveVersionMajor == detected, "Hive version major expected: %s, but was detected as: %s", hiveVersionMajor, detected);
            hiveVersionMajorVerified = true;
        }
        return hiveVersionMajor;
    }

    private static int detectHiveVersionMajor()
    {
        try {
            return onHive().getConnection().getMetaData().getDatabaseMajorVersion();
        }
        catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}

Verify Hive version major in product tests


/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.http.client;

import org.junit.Test;

import org.springframework.http.HttpMethod;

/**
 * @author Luciano Leggieri
 */
public class OkHttpClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {

	@Override
	protected ClientHttpRequestFactory createRequestFactory() {
		return new OkHttpClientHttpRequestFactory();
	}

	@Override
	@Test
	public void httpMethods() throws Exception {
		assertHttpMethod("patch", HttpMethod.PATCH);
	}

}

/*
 * Copyright 2002-2015 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.http.client;

import org.junit.Test;

import org.springframework.http.HttpMethod;

/**
 * @author Luciano Leggieri
 */
public class OkHttpClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase {

	@Override
	protected ClientHttpRequestFactory createRequestFactory() {
		return new OkHttpClientHttpRequestFactory();
	}

	@Override
	@Test
	public void httpMethods() throws Exception {
		super.httpMethods();
		assertHttpMethod("patch", HttpMethod.PATCH);
	}

}

Add missing super in test

Add missing super in test

Closes gh-814


package com.rarchives.ripme.tst.ripper.rippers;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import com.rarchives.ripme.ripper.rippers.ErotivRipper;
import org.junit.jupiter.api.Test;

public class ErotivRipperTest extends RippersTest {
	@Test
	public void testGetGID() throws IOException {
		URL url = new URL("https://erotiv.io/e/1568314255");
		ErotivRipper ripper = new ErotivRipper(url);
		assertEquals("1568314255", ripper.getGID(url));
	}

	public void testRip() throws IOException {
		URL url = new URL("https://erotiv.io/e/1568314255");
		ErotivRipper ripper = new ErotivRipper(url);
		testRipper(ripper);
	}
	@Test
	public void testGetURLsFromPage() throws IOException {
		URL url = new URL("https://erotiv.io/e/1568314255");
		ErotivRipper ripper = new ErotivRipper(url);
		assert (1 == ripper.getURLsFromPage(ripper.getFirstPage()).size());
	}
}

package com.rarchives.ripme.tst.ripper.rippers;

import java.io.IOException;
import java.net.URL;

import com.rarchives.ripme.ripper.rippers.ErotivRipper;
import org.junit.jupiter.api.Test;

public class ErotivRipperTest extends RippersTest {
    @Test
    public void testGetGID() throws IOException {
        URL url = new URL("https://erotiv.io/e/1568314255");
        ErotivRipper ripper = new ErotivRipper(url);
        assert("1568314255".equals(ripper.getGID(url)));
    }

    public void testRip() throws IOException {
        URL url = new URL("https://erotiv.io/e/1568314255");
        ErotivRipper ripper = new ErotivRipper(url);
        testRipper(ripper);
    }

    @Test
    public void testGetURLsFromPage() throws IOException {
        URL url = new URL("https://erotiv.io/e/1568314255");
        ErotivRipper ripper = new ErotivRipper(url);
        assert(1 == ripper.getURLsFromPage(ripper.getFirstPage()).size());
    }
}

Fix indentation, remove unused import, avoid deprecated method


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.navalplanner.business.resources.entities;

import java.util.List;

/**
 *
 * @author Diego Pino Garcia<dpino@igalia.com>
 */
public enum ResourceEnum {

    RESOURCE(Resource.class),
    WORKER(Worker.class);

    Class clase;

    private ResourceEnum(Class clase) {
        this.clase = clase;
    }

    public Class asClass() {
        return clase;
    }

    public static ResourceEnum getDefault() {
        return RESOURCE;
    }

    public boolean isAssignableFrom(Class clase) {
        return asClass().equals(clase);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.navalplanner.business.resources.entities;

import java.util.List;

/**
 *
 * @author Diego Pino Garcia<dpino@igalia.com>
 */
public enum ResourceEnum {

    RESOURCE(Resource.class),
    WORKER(Worker.class);

    Class clase;

    private ResourceEnum(Class clase) {
        this.clase = clase;
    }

    public Class asClass() {
        return clase;
    }

    public static ResourceEnum getDefault() {
        return RESOURCE;
    }

    public boolean isAssignableFrom(Class clase) {
        return asClass().isAssignableFrom(clase);
    }
}

ItEr16S10ClasificacionTraballoItEr15S13: Fix bug to let add a CriterionSatisfaction to Resource super class or
subclass.

If a CriterionType has in the resource column an enum matching the Resource super class, it has to be possible to
assign it to a subclass of Resource (Worker).


package com.jetbrains.python.documentation.doctest;

import com.intellij.lang.InjectableLanguage;
import com.intellij.lang.Language;
import com.jetbrains.python.PythonLanguage;

/**
 * User : ktisha
 */
public class PyDocstringLanguageDialect extends Language implements InjectableLanguage {
  public static PyDocstringLanguageDialect getInstance() {
    return (PyDocstringLanguageDialect)PyDocstringFileType.INSTANCE.getLanguage();
  }

  protected PyDocstringLanguageDialect() {
    super(PythonLanguage.getInstance(), "PyDocstring");
  }
}

package com.jetbrains.python.documentation.doctest;

import com.intellij.codeInsight.intention.impl.QuickEditAction;
import com.intellij.lang.InjectableLanguage;
import com.intellij.lang.Language;
import com.jetbrains.python.PythonLanguage;

/**
 * User : ktisha
 */
public class PyDocstringLanguageDialect extends Language implements InjectableLanguage {
  public static PyDocstringLanguageDialect getInstance() {
    return (PyDocstringLanguageDialect)PyDocstringFileType.INSTANCE.getLanguage();
  }

  protected PyDocstringLanguageDialect() {
    super(PythonLanguage.getInstance(), "PyDocstring");
    putUserData(QuickEditAction.EDIT_ACTION_AVAILABLE, false);
  }
}

Edit injection language fragment action is not available for Python Docstring language


package org.tinylog.impl.format.pattern.placeholders;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

import org.tinylog.core.Framework;
import org.tinylog.core.internal.InternalLogger;

/**
 * Builder for creating an instance of {@link DatePlaceholder}.
 */
public class DatePlaceholderBuilder implements PlaceholderBuilder {

	private static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";

	/** */
	public DatePlaceholderBuilder() {
	}

	@Override
	public String getName() {
		return "date";
	}

	@Override
	public Placeholder create(Framework framework, String value) {
		String pattern = value == null ? DEFAULT_PATTERN : value;
		Locale locale = framework.getConfiguration().getLocale();
		ZoneId zone = framework.getConfiguration().getZone();

		try {
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern, locale);
			return new DatePlaceholder(formatter.withZone(zone), value != null);
		} catch (IllegalArgumentException ex) {
			InternalLogger.error(ex, "Invalid date time pattern: \"{}\"", pattern);
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_PATTERN, locale);
			return new DatePlaceholder(formatter.withZone(zone), false);
		}
	}

}

package org.tinylog.impl.format.pattern.placeholders;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

import org.tinylog.core.Framework;
import org.tinylog.core.internal.InternalLogger;

/**
 * Builder for creating an instance of {@link DatePlaceholder}.
 */
public class DatePlaceholderBuilder implements PlaceholderBuilder {

	private static final String DEFAULT_PATTERN = "yyyy-MM-dd HH:mm:ss";

	/** */
	public DatePlaceholderBuilder() {
	}

	@Override
	public String getName() {
		return "date";
	}

	@Override
	public Placeholder create(Framework framework, String value) {
		String pattern = value == null ? DEFAULT_PATTERN : value;
		Locale locale = framework.getConfiguration().getLocale();
		ZoneId zone = framework.getConfiguration().getZone();

		try {
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern, locale);
			return new DatePlaceholder(formatter.withZone(zone), value != null);
		} catch (IllegalArgumentException ex) {
			InternalLogger.error(ex, "Invalid date-time pattern: \"{}\"", pattern);
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DEFAULT_PATTERN, locale);
			return new DatePlaceholder(formatter.withZone(zone), false);
		}
	}

}

Add hyphen to date-time pattern

Add hyphen to date-time pattern


package org.luxons.sevenwonders.config;

import java.security.Principal;

import org.luxons.sevenwonders.validation.DestinationAccessValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
import org.springframework.stereotype.Component;

@Component
public class TopicSubscriptionInterceptor extends ChannelInterceptorAdapter {

    private final DestinationAccessValidator destinationAccessValidator;

    @Autowired
    public TopicSubscriptionInterceptor(DestinationAccessValidator destinationAccessValidator) {
        this.destinationAccessValidator = destinationAccessValidator;
    }

    @Override
    public Message<?> preSend(Message<?> message, MessageChannel channel) {
        StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(message);
        if (StompCommand.SUBSCRIBE.equals(headerAccessor.getCommand())) {
            Principal userPrincipal = headerAccessor.getUser();
            if (!destinationAccessValidator.hasAccess(userPrincipal.getName(), headerAccessor.getDestination())) {
                throw new ForbiddenSubscriptionException();
            }
        }
        return message;
    }

    private static class ForbiddenSubscriptionException extends RuntimeException {
    }
}

package org.luxons.sevenwonders.config;

import org.luxons.sevenwonders.errors.ApiMisuseException;
import org.luxons.sevenwonders.validation.DestinationAccessValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
import org.springframework.stereotype.Component;

@Component
public class TopicSubscriptionInterceptor extends ChannelInterceptorAdapter {

    private final DestinationAccessValidator destinationAccessValidator;

    @Autowired
    public TopicSubscriptionInterceptor(DestinationAccessValidator destinationAccessValidator) {
        this.destinationAccessValidator = destinationAccessValidator;
    }

    @Override
    public Message<?> preSend(Message<?> message, MessageChannel channel) {
        StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(message);
        if (StompCommand.SUBSCRIBE.equals(headerAccessor.getCommand())) {
            String username = headerAccessor.getUser().getName();
            String destination = headerAccessor.getDestination();
            if (!destinationAccessValidator.hasAccess(username, destination)) {
                throw new ForbiddenSubscriptionException(username, destination);
            }
        }
        return message;
    }

    private static class ForbiddenSubscriptionException extends ApiMisuseException {

        ForbiddenSubscriptionException(String username, String destination) {
            super(String.format("Player '%s' is not allowed to access %s", username, destination));
        }
    }
}

Improve forbidden subscription exception message


package com.geektime.rnonesignalandroid;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Avishay on 1/31/16.
 */
public class ReactNativeOneSignalPackage implements ReactPackage {

    RNOneSignal mRNPushNotification;

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        mRNPushNotification = new RNOneSignal(reactContext);

        modules.add(mRNPushNotification);
        return modules;
    }

    @Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return new ArrayList<>();
    }
}

package com.geektime.rnonesignalandroid;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Avishay on 1/31/16.
 */
public class ReactNativeOneSignalPackage implements ReactPackage {

    RNOneSignal mRNPushNotification;

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        mRNPushNotification = new RNOneSignal(reactContext);

        modules.add(mRNPushNotification);
        return modules;
    }

    // Deprecated RN 0.47
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return new ArrayList<>();
    }
}

Remove depreciated createJSModules @ovveride marker


package org.hibernate.ogm.test.simpleentity;

import org.hibernate.Session;

/**
 * @author Emmanuel Bernard
 */
public class BootstrapTest extends OgmTestCase {

	public void testBootstrap() throws Exception {
		final Session session = openSession();
		session.close();
	}

	@Override
	protected Class<?>[] getAnnotatedClasses() {
		return new Class<?>[] {
				Hypothesis.class
		};
	}
}

package org.hibernate.ogm.test.simpleentity;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * @author Emmanuel Bernard
 */
public class BootstrapTest extends OgmTestCase {

	public void testBootstrap() throws Exception {
		final Session session = openSession();
		Hypothesis hyp = new Hypothesis();
		hyp.setId( "1234567890" );
		hyp.setDescription( "P != NP" );
		final Transaction transaction = session.beginTransaction();
		session.persist( hyp );
		session.flush();
		session.clear();
		final Hypothesis loadedHyp = (Hypothesis) session.get( Hypothesis.class, hyp.getId() );
		assertEquals( hyp.getDescription(), loadedHyp.getDescription() );
		transaction.rollback();
		session.close();
	}

	@Override
	protected Class<?>[] getAnnotatedClasses() {
		return new Class<?>[] {
				Hypothesis.class
		};
	}
}

Improve test to add insertion and subsequent read


package io.quarkus.it.mailer;

import java.util.HashMap;
import java.util.Map;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class FakeMailerTestResource implements QuarkusTestResourceLifecycleManager {

    public GenericContainer<?> server = new GenericContainer<>("reachfive/fake-smtp-server:latest")
            .withExposedPorts(1080, 1025)
            .waitingFor(Wait.forHttp("/api/emails"));

    @Override
    public Map<String, String> start() {
        server.start();
        HashMap<String, String> properties = new HashMap<>();
        properties.put("quarkus.mailer.port", Integer.toString(server.getMappedPort(1025)));
        properties.put("quarkus.mailer.host", server.getContainerIpAddress());
        properties.put("fake.mailer", server.getContainerIpAddress() + ":" + server.getMappedPort(1080));
        //        properties.put("quarkus.mailer.port", Integer.toString(32787));
        //        properties.put("quarkus.mailer.host", "localhost");
        //        properties.put("fake.mailer", "localhost" + ":" + 32786);
        return properties;
    }

    @Override
    public void stop() {
        server.close();
    }
}

package io.quarkus.it.mailer;

import java.util.HashMap;
import java.util.Map;

import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class FakeMailerTestResource implements QuarkusTestResourceLifecycleManager {

    public GenericContainer<?> server = new FixedHostPortGenericContainer<>("reachfive/fake-smtp-server:latest")
            .withFixedExposedPort(9155, 1080)
            .withFixedExposedPort(9156, 1025)
            .waitingFor(Wait.forHttp("/api/emails"));

    @Override
    public Map<String, String> start() {
        server.start();
        HashMap<String, String> properties = new HashMap<>();
        properties.put("quarkus.mailer.port", Integer.toString(server.getMappedPort(1025)));
        properties.put("quarkus.mailer.host", server.getContainerIpAddress());
        properties.put("fake.mailer", server.getContainerIpAddress() + ":" + server.getMappedPort(1080));
        //        properties.put("quarkus.mailer.port", Integer.toString(32787));
        //        properties.put("quarkus.mailer.host", "localhost");
        //        properties.put("fake.mailer", "localhost" + ":" + 32786);
        return properties;
    }

    @Override
    public void stop() {
        server.close();
    }
}

Use fixed port for mailer test

Use fixed port for mailer test

This is done to avoid the flakiness we are seeing in CI


package org.adaptlab.chpir.android.participanttracker.validators;

/**
 * Created by mn127 on 3/3/15.
 */
public class CaregiverIdValidator extends ParticipantIdValidator {

    @Override
    public boolean validate(String value) {
        if (value.length() > 0) {
            return value.charAt(0) == 'E' && super.validate(value);
        }

        return false;
    }
}

package org.adaptlab.chpir.android.participanttracker.validators;

public class CaregiverIdValidator extends ParticipantIdValidator {

    @Override
    public boolean validate(String value) {
        if (value.length() > 0) {
            return value.charAt(0) == 'E' && super.validate(value);
        }

        return false;
    }
}

Clean up comments for caregiver id validator


/*
 * Copyright 2017 The Bazel Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.idea.blaze.terminal;

import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.intellij.openapi.project.Project;
import javax.annotation.Nullable;
import org.jetbrains.plugins.terminal.LocalTerminalCustomizer;

/** Set the default terminal path to the workspace root. */
public class DefaultTerminalLocationCustomizer extends LocalTerminalCustomizer {

  @Override
  @Nullable
  protected String getDefaultFolder(Project project) {
    WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(project);
    return root != null ? root.toString() : null;
  }
}

/*
 * Copyright 2017 The Bazel Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.idea.blaze.terminal;

import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
import com.intellij.openapi.project.Project;
import java.util.Map;
import javax.annotation.Nullable;
import org.jetbrains.plugins.terminal.LocalTerminalCustomizer;

/** Set the default terminal path to the workspace root. */
public class DefaultTerminalLocationCustomizer extends LocalTerminalCustomizer {

  @Override
  @Nullable
  protected String getDefaultFolder(Project project) {
    return getWorkspaceRootPath(project);
  }

  @Override
  public String[] customizeCommandAndEnvironment(
      Project project, String[] command, Map<String, String> envs) {
    String workspaceRootPath = getWorkspaceRootPath(project);
    if (workspaceRootPath != null) {
      envs.put("PWD", workspaceRootPath);
    }
    return super.customizeCommandAndEnvironment(project, command, envs);
  }

  @Nullable
  private static String getWorkspaceRootPath(Project project) {
    WorkspaceRoot root = WorkspaceRoot.fromProjectSafe(project);
    return root != null ? root.toString() : null;
  }
}

Set PWD env var when customizing Terminal plugin working directory.

PiperOrigin-RevId: 359567768


package org.lagonette.app.room.statement;

public abstract class MapPartnerStatement
        extends Statement {

    // TODO Why only 87 partners returned ??
    public static final String SQL =
            "SELECT partner.id, " +
                "partner.latitude, " +
                "partner.longitude, " +
                "partner.is_exchange_office, " +
                "partner.main_category_id, " +
                "main_category.icon " +
            "FROM partner " +
            "JOIN partner_metadata " +
                "ON partner.id = partner_metadata.partner_id " +
            "JOIN category AS main_category " +
                "ON partner.main_category_id = main_category.id " +
            "JOIN category_metadata AS main_category_metadata " +
                "ON main_category.id = main_category_metadata.category_id " +
            "LEFT JOIN partner_side_category " +
                "ON partner.id = partner_side_category.partner_id " +
            "LEFT JOIN category AS side_category " +
                "ON partner_side_category.category_id = side_category.id " +
            "LEFT JOIN category_metadata AS side_category_metadata " +
                "ON side_category.id = side_category_metadata.category_id " +
            "WHERE partner.name LIKE :search " +
                "AND partner.is_localizable <> 0 " +
            "GROUP BY partner.id " +
            "HAVING partner_metadata.is_visible > 0 " +
                "AND SUM (side_category_metadata.is_visible) > 0";

}

package org.lagonette.app.room.statement;

public abstract class MapPartnerStatement
        extends Statement {

    // TODO Why only 87 partners returned ??
    public static final String SQL =
            "SELECT partner.id, " +
                "partner.latitude, " +
                "partner.longitude, " +
                "partner.is_exchange_office, " +
                "partner.main_category_id, " +
                "main_category.icon " +
            "FROM partner " +
            "JOIN partner_metadata " +
                "ON partner.id = partner_metadata.partner_id " +
            "JOIN category AS main_category " +
                "ON partner.main_category_id = main_category.id " +
            "JOIN category_metadata AS main_category_metadata " +
                "ON main_category.id = main_category_metadata.category_id " +
            "LEFT JOIN partner_side_category " +
                "ON partner.id = partner_side_category.partner_id " +
            "LEFT JOIN category AS side_category " +
                "ON partner_side_category.category_id = side_category.id " +
            "LEFT JOIN category_metadata AS side_category_metadata " +
                "ON side_category.id = side_category_metadata.category_id " +
            "WHERE partner.name LIKE :search " +
                "AND partner.is_localizable <> 0 " +
            "GROUP BY partner.id " +
            "HAVING partner_metadata.is_visible + TOTAL (side_category_metadata.is_visible) > 0";

}

Fix map partner SQL request

Fix map partner SQL request


package org.gbif.checklistbank.ws.resources;

import java.security.Permission;

import org.gbif.ws.app.Application;
import org.junit.Test;

import static org.junit.Assert.fail;

public class WsAppTest {

  /**
   * Test the startup of the webapp.
   * We expect a SecurityException raised as the Application stops because of missing configs.
   * But no NoSuchMethodError thrown by incompatible jackson we see with a wrong version introduced by solr
   */
  @Test(expected = SecurityException.class)
  public void testWsStartup() {
    // throw exception if Application exits
    System.setSecurityManager(new NoExitSecurityManager());
    Application.main(new String[]{});
  }

  private static class NoExitSecurityManager extends SecurityManager {
    @Override
    public void checkPermission(Permission perm) {
      // allow anything.
    }
    @Override
    public void checkPermission(Permission perm, Object context) {
      // allow anything.
    }

    @Override
    public void checkExit(int status) {
      super.checkExit(status);
      throw new SecurityException("Exit status " + status + " called");
    }
  }
}

package org.gbif.checklistbank.ws.resources;

import java.security.Permission;

import org.gbif.ws.app.Application;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.fail;

public class WsAppTest {
  private SecurityManager sm;

  @Before
  public void init(){
    sm = System.getSecurityManager();
    System.setSecurityManager(new NoExitSecurityManager());
  }

  @After
  public void shutdown(){
    System.setSecurityManager(sm);
  }

  /**
   * Test the startup of the webapp.
   * We expect a ExitException raised as the Application stops because of missing configs.
   * But no NoSuchMethodError thrown by incompatible jackson we see with a wrong version introduced by solr
   */
  @Test(expected = ExitException.class)
  public void testWsStartup() {
    Application.main(new String[]{});
  }

  public static class ExitException extends RuntimeException {
    public ExitException(int status) {
      super("Exit status " + status + " called");
    }
  }

  private static class NoExitSecurityManager extends SecurityManager {
    @Override
    public void checkPermission(Permission perm) {
      // allow anything.
    }
    @Override
    public void checkPermission(Permission perm, Object context) {
      // allow anything.
    }

    @Override
    public void checkExit(int status) {
      super.checkExit(status);
      throw new ExitException(status);
    }
  }
}

Remove custom security manager after test finishes


/*
 * Copyright 2016 Erik Wramner.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package name.wramner.jmstools.messages;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

/**
 * A message provider can create JMS messages enriched with a checksum property that can be checked on the other side.
 *
 * @author Erik Wramner
 */
public interface MessageProvider {
    static final String UNIQUE_MESSAGE_ID_PROPERTY_NAME = "Unique-Message-Id";
    static final String CHECKSUM_PROPERTY_NAME = "Payload-Checksum-MD5";
    static final String LENGTH_PROPERTY_NAME = "Payload-Length";

    /**
     * Create message with checksum and length properties.
     *
     * @param session The JMS session.
     * @return message.
     * @throws JMSException on JMS errors.
     */
    Message createMessageWithPayloadAndChecksumProperty(Session session) throws JMSException;
}

/*
 * Copyright 2016 Erik Wramner.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package name.wramner.jmstools.messages;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

/**
 * A message provider can create JMS messages enriched with a checksum property that can be checked on the other side.
 * <p>
 * Note that according to the JMS standard property names must follow the same rules as Java identifiers.
 *
 * @author Erik Wramner
 */
public interface MessageProvider {
    static final String UNIQUE_MESSAGE_ID_PROPERTY_NAME = "EWJMSToolsUniqueMessageId";
    static final String CHECKSUM_PROPERTY_NAME = "EWJMSToolsPayloadChecksumMD5";
    static final String LENGTH_PROPERTY_NAME = "EWJMSToolsPayloadLength";

    /**
     * Create message with checksum and length properties.
     *
     * @param session The JMS session.
     * @return message.
     * @throws JMSException on JMS errors.
     */
    Message createMessageWithPayloadAndChecksumProperty(Session session) throws JMSException;
}

Rename property names to follow JMS standard for identifiers.


package devopsdistilled.operp.client.abstracts;

import java.io.Serializable;
import java.util.List;

import devopsdistilled.operp.server.data.entity.Entiti;
import devopsdistilled.operp.server.data.service.EntityService;

public interface EntityModel<E extends Entiti, ES extends EntityService<E, ID>, EO extends EntityObserver, ID extends Serializable>
		extends Model<EO> {

	public List<E> getEntities();

	void setEntities(List<E> entities);

	public ES getService();

}

package devopsdistilled.operp.client.abstracts;

import java.io.Serializable;
import java.util.List;

import devopsdistilled.operp.server.data.entity.Entiti;
import devopsdistilled.operp.server.data.service.EntityService;

public interface EntityModel<E extends Entiti, ES extends EntityService<E, ID>, EO extends EntityObserver, ID extends Serializable>
		extends Model<EO> {

	public List<E> getEntities();

	void setEntities(List<E> entities);

	public ES getService();

	public E saveAndUpdateModel(E entity);

}

Add saveAndUpdateModel() method to save entity and update the model


package io.georocket.index.xml;

import io.georocket.index.generic.BoundingBoxIndexerFactory;

/**
 * Create instances of {@link BoundingBoxIndexer}
 * @author Michel Kraemer
 */
public class XMLBoundingBoxIndexerFactory extends BoundingBoxIndexerFactory implements XMLIndexerFactory {
  @Override
  public XMLIndexer createIndexer() {
    return new BoundingBoxIndexer();
  }
}

package io.georocket.index.xml;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import io.georocket.index.generic.BoundingBoxIndexerFactory;

/**
 * Create instances of {@link BoundingBoxIndexer}
 * @author Michel Kraemer
 */
public class XMLBoundingBoxIndexerFactory extends BoundingBoxIndexerFactory
    implements XMLIndexerFactory {
  private static final String PROPERTIES_FILENAME =
    "io.georocket.index.xml.XMLBoundingBoxIndexerFactory.properties";
  private static final String BOUNDINGBOXINDEXER_CLASSNAME =
    "io.georocket.index.xml.BoundingBoxIndexer";
  private static Class<? extends BoundingBoxIndexer> configuredClass;

  static {
    loadConfig();
  }

  @SuppressWarnings("unchecked")
  private static void loadConfig() {
    try (InputStream is = XMLBoundingBoxIndexerFactory.class.getClassLoader()
        .getResourceAsStream(PROPERTIES_FILENAME)) {
      if (is != null) {
        Properties p = new Properties();
        p.load(is);
        String cls = p.getProperty(BOUNDINGBOXINDEXER_CLASSNAME);
        if (cls != null) {
          try {
            configuredClass = (Class<? extends BoundingBoxIndexer>)Class.forName(cls);
          } catch (ClassNotFoundException e) {
            throw new RuntimeException("Could not find custom "
              + "BoundingBoxIndexer class: " + cls, e);
          }
        }
      }
    } catch (IOException e) {
      // ignore
    }
  }

  @Override
  public XMLIndexer createIndexer() {
    if (configuredClass == null) {
      return new BoundingBoxIndexer();
    }
    try {
      return configuredClass.newInstance();
    } catch (ReflectiveOperationException e) {
      throw new RuntimeException("Could not create custom "
        + "BoundingBoxIndexer", e);
    }
  }
}

Add possibility to override the default BoundingBoxIndexer


/*
 * Copyright 2011 Splunk, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"): you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import com.splunk.Entity;

import org.openide.nodes.Children;

class EntityNode extends ExplorerNode {
    EntityNode(Entity entity) {
        super(entity);
        String name = entity.getName();
        setName(name);
        setDisplayName(name);
    }

    protected PropertyList getMetadata() {
        return new PropertyList() {{
            add(String.class, "getTitle");
        }};
    }
}

/*
 * Copyright 2011 Splunk, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"): you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

import com.splunk.Entity;

import org.openide.nodes.Children;

class EntityNode extends ExplorerNode {
    EntityNode(Entity entity) {
        super(entity);
        setDisplayName(entity.getName());
    }

    protected PropertyList getMetadata() {
        return new PropertyList() {{
            add(String.class, "getPath");
            add(String.class, "getTitle");
        }};
    }
}

Add path property to base entity node.

Add path property to base entity node.